/// <summary> /// Finds all visible assets of the given type. /// </summary> public static List <T> AllVisibleAssetsOfType <T> () where T : ScriptableObject { List <T> result = new List <T> (); object filteredHierarchy = CreateFilteredHierarchy(); #if UNITY_3_5 UTInternalCall.Set(filteredHierarchy, "filter", typeof(T).Name); UTInternalCall.Set(filteredHierarchy, "searchMode", UTInternalCall.EnumValue("UnityEditor.FilteredHierarchy+SearchMode", "Type")); #else var searchFilter = UTInternalCall.InvokeStatic("UnityEditor.SearchableEditorWindow", "CreateFilter", typeof(T).Name, UTInternalCall.EnumValue("UnityEditor.SearchableEditorWindow+SearchMode", "Type")); UTInternalCall.Set(filteredHierarchy, "searchFilter", searchFilter); #endif var hierarchyProperty = UTInternalCall.InvokeStatic("UnityEditor.FilteredHierarchyProperty", "CreateHierarchyPropertyForFilter", filteredHierarchy); var emptyIntArray = new int[0]; while ((bool)UTInternalCall.Invoke(hierarchyProperty, "Next", emptyIntArray)) { var instanceId = (int)UTInternalCall.Get(hierarchyProperty, "instanceID"); var path = AssetDatabase.GetAssetPath(instanceId); T t = AssetDatabase.LoadAssetAtPath(path, typeof(T)) as T; if (t != null) { result.Add(t); } } return(result); }
/// <summary> /// Evaluate the specified input and replaces all known placeholders. Placeholders can be written as /// $foo.bar or optionally $(foo.bar) in case the first notation is ambiguous. /// /// You can write arbitrary JavaScript expressions like: /// /// 2 + 2 (yields 4) /// '2' + '2' (yields '22') /// '2' == '2' (yields true) /// etc.. /// /// Please note that properties can have different types and casting/transformation is not performed /// automatically. E.g. If the property "foo" has the value "2" (as a string) $foo * 2 will yield "22" /// because it is a string. If you want to have the numeric value use parseInt($foo) * 2 (will yield 4). /// /// </summary> /// <param name='input'> /// The input string. /// </param> public object Evaluate(string input) { var replaced = Regex.Replace(input, PlaceholderRegexp, "context['$1']"); try { // we call this via reflection because we cannot reference unityscript stuff directly return(UTInternalCall.InvokeStatic("UTEval", "Evaluate", replaced, this)); } catch (Exception e) { throw new UTFailBuildException("Unparseable expression: '" + input + "' " + e.Message, null); // no experiments. } }
public override IEnumerator Execute(UTContext context) { UDebug.LogWarning("This action is experimental and might break.", this); bool connError = (bool)UTInternalCall.InvokeStatic("UnityEditor.AssetServer", "HasConnectionError"); if (connError) { throw new UTFailBuildException("Currently unable to connect to the asset server.", this); } UDebug.Log("Not working properly..."); throw new UTFailBuildException("Not implemented.", this); /* * UDebug.Log("Starting update..."); * Process process = new Process(); * process.StartInfo.FileName = GetEditorExecutable(); * process.StartInfo.Arguments = "-batchMode -assetServerUpdate " + string.Join(" ", new string[] {assetServerLocation, projectOnAssetServer, username, password}); * process.StartInfo.RedirectStandardOutput = true; * process.StartInfo.UseShellExecute = false; * process.OutputDataReceived += (sender, args) => UDebug.Log("[Unity]"+ args.Data); * try { * process.Start(); * process.BeginOutputReadLine(); * process.WaitForExit(); * if (process.ExitCode != 0) { * UDebug.LogError("Update failed."); * return false; * } * * } * catch(Win32Exception e) { * UDebug.LogError("Couldn't start process: " + e.Message); * return false; * } * return true;*/ }
/// <summary> /// Hides the async progress bar. /// </summary> public static void ClearAsyncProgressBar() { UTInternalCall.InvokeStatic("UnityEditor.AsyncProgressBar", "Clear"); }
/// <summary> /// Shows an async progress bar in the lower right corner of Unity's window (like the one shown when /// rendering lightmaps). /// </summary> /// <param name='text'> /// Text to show. /// </param> /// <param name='progress'> /// Progress to show (anything between 0f and 1f) /// </param> public static void ShowAsyncProgressBar(string text, float progress) { UTInternalCall.InvokeStatic("UnityEditor.AsyncProgressBar", "Display", text, progress); }
/// <summary> /// Clears Unity's console. /// </summary> public static void ClearConsole() { UTInternalCall.InvokeStatic("UnityEditorInternal.LogEntries", "Clear"); }
/// <summary> /// Checks if the build pipeline supports the given build target. /// </summary> public static bool IsBuildTargetSupported(BuildTarget target) { return((bool)UTInternalCall.InvokeStatic("UnityEditor.BuildPipeline", "IsBuildTargetSupported", target)); }