VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
static void AVR.Core.AVR_Core_ConsoleCommands.SetSearch ( string  searchstring)
inlinestaticprivate

Definition at line 130 of file AVR_Core_ConsoleCommands.cs.

131  {
132  try
133  {
134  // Get type UnityEditor.ProjectBrowser from the UnityEditor Assembly
135  // Check https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/ProjectBrowser.cs
136  // for source code on this class
137  System.Type upb_t = System.Type.GetType("UnityEditor.ProjectBrowser, UnityEditor");
138 
139  // Get the first object of this type
140  Object projectBrowser = Resources.FindObjectsOfTypeAll(upb_t)[0];
141  if (projectBrowser == null)
142  {
143  AVR_DevConsole.error("Could not get an active ProjectBrowser.");
144  return;
145  }
146 
147  //// Set Searchstring
148  // get method SeatSearch(string) from UnityEditor.ProjectBrowser object
149  System.Reflection.MethodInfo setSearchInfo = upb_t.GetMethod("SetSearch", new[] { typeof(string) });
150 
151  setSearchInfo.Invoke(projectBrowser, new object[] { searchstring });
152  }
153  catch (System.Exception e)
154  {
155  AVR_DevConsole.error("Encountered an exception while setting search-string. Do you not have a ProjectBrowser open, or are you using a different Unity version?");
156  AVR_DevConsole.error("Stacktrace: " + e.StackTrace);
157  }
158  }