private static void CheckCallDelayed() { if (Time.realtimeSinceStartup > EditorApplication.s_DelayedCallbackTime) { EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(EditorApplication.CheckCallDelayed)); EditorApplication.delayedCallback(); } }
static private WWW LoadXMLFromWWW(string url, Action <XmlDocument> resultHandler) { WWW www = new WWW(url); EditorApplication.CallbackFunction handler = null; handler = () => { if (www.isDone) { EditorApplication.update -= handler; string t = www.text; www.Dispose(); www = null; int startIndex = t.IndexOf("<tbody>"); int endIndex = t.IndexOf("</tbody>") + "</tbody>".Length; t = t.Substring(startIndex, endIndex - startIndex).Replace(" ", "").Replace("\n", ""); XmlDocument xml = null; try { xml = new XmlDocument(); xml.LoadXml(t); } catch (XmlException e) { Debug.Log(e.ToString()); xml = null; } resultHandler(xml); } }; EditorApplication.update += handler; return(www); }
/// <summary> /// Run the code in Unity thread. /// </summary> /// <param name="callback"> /// The delegate that contains code should be run on Unity thread. /// </param> public static void RunInUnityThread(UnityAction callback) { if (callback == null) { throw new ArgumentNullException("callback"); } if (IsInUnityThread) { callback.Invoke(); return; } #if UNITY_EDITOR EditorApplication.CallbackFunction wrapped = null; wrapped = () => { EditorApplication.update -= wrapped; try { callback.Invoke(); } catch (Exception ex) { Debug.LogException(ex); } }; EditorApplication.update += wrapped; #else threadHandler.Enqueue(callback); #endif }
public static void ChangeGameViewSize(int width, int height) { m_width = width; m_height = height; callback = new EditorApplication.CallbackFunction(Update); EditorApplication.update += callback; }
static void Wait(WWW www, EditorApplication.CallbackFunction caller, Action <WWW> action, Action done = null) { if (www != null && www.isDone) { EditorApplication.update -= caller; if (string.IsNullOrEmpty(www.error) && www.bytesDownloaded > 0) { //Debug.LogFormat("{0} kB: {1}", www.size/1024, www.url); if (action != null) { action(www); } if (done != null) { done(); } } else { Debug.LogWarningFormat("{0} {1}", www.url, www.error); } www = null; } else { if (www == null) { EditorApplication.update -= caller; } } }
public void LoadSceneAsync(string sceneName, LoadSceneMode mode, Action onSuccess) { Log.Trace("[ilib-abloader] EditorContainer {0}, LoadSceneAsync {1}. mode{2}", m_Name, sceneName, mode); var paths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(m_Name, sceneName); if (paths.Length == 0) { onSuccess?.Invoke(); return; } LoadSceneParameters parameters = new LoadSceneParameters(mode); EditorSceneManager.LoadSceneAsyncInPlayMode(paths[0], parameters); //Asyncのコールバックが正常に動かないので無理やり実装 var scene = EditorSceneManager.GetSceneByPath(paths[0]); EditorApplication.CallbackFunction onLoad = null; onLoad = () => { if (scene.isLoaded || !scene.IsValid()) { EditorApplication.update -= onLoad; onSuccess?.Invoke(); } }; EditorApplication.update += onLoad; }
static void EditorStartCoroutine(IEnumerator coroutine) { if (!coroutine.MoveNext()) { return; } EditorApplication.CallbackFunction callback = null; callback = () => { if (coroutine.Current != null) { var oper = coroutine.Current as AsyncOperation; if (oper != null) { if (!oper.isDone) { EditorApplication.update += callback; return; } } if (coroutine.MoveNext()) { EditorApplication.update += callback; } } }; EditorApplication.update += callback; }
public static void Process() { #if UNITY_4 || UNITY_5 || UNITY_2017 || UNITY_2018 || UNITY_2019 EditorApplication.delayCall -= onDelayCall; EditorApplication.delayCall += onDelayCall; #endif EditorApplication.update -= onUpdate; EditorApplication.update += onUpdate; // globalEventHandler EditorApplication.CallbackFunction function = () => onGlobalEventHandler(Event.current); FieldInfo info = typeof(EditorApplication).GetField("globalEventHandler", BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic); EditorApplication.CallbackFunction functions = (EditorApplication.CallbackFunction)info.GetValue(null); functions += function; info.SetValue(null, (object)functions); EditorApplication.contextualPropertyMenu -= onContextualPropertyMenu; EditorApplication.contextualPropertyMenu += onContextualPropertyMenu; EditorApplication.modifierKeysChanged -= onModifierKeysChanged; EditorApplication.modifierKeysChanged += onModifierKeysChanged; EditorApplication.searchChanged -= onSearchChanged; EditorApplication.searchChanged += onSearchChanged; #if UNITY_2017_2_OR_NEWER EditorApplication.playModeStateChanged -= onPlayModeStateChanged; EditorApplication.playModeStateChanged += onPlayModeStateChanged; #else EditorApplication.playmodeStateChanged -= onPlayModeStateChanged; EditorApplication.playmodeStateChanged += onPlayModeStateChanged; #endif }
public static bool Highlight(string windowTitle, string text, HighlightSearchMode mode) { bool flag = false; if (Highlighter.s_RecursionLock || Highlighter.searching) { Debug.LogWarning("Highlighter recursion detected. You are calling Highlighter.Highlight() with too much abandon. Avoid highlighting during layout and repaint events."); } else if (Event.current != null && Event.current.type == EventType.Layout) { Debug.LogWarning("You are calling Highlighter.Highlight() inorrectly. Avoid highlighting during layout and repaint events."); } else { Highlighter.s_RecursionLock = true; Highlighter.Stop(); if (!Highlighter.SetWindow(windowTitle)) { Debug.LogWarning("Window " + windowTitle + " not found."); } else if (mode != HighlightSearchMode.None) { Highlighter.active = true; Highlighter.activeText = text; Highlighter.s_SearchMode = mode; Highlighter.s_LastTime = Time.realtimeSinceStartup; flag = Highlighter.Search(); if (flag) { Delegate arg_D8_0 = EditorApplication.update; if (Highlighter.< > f__mg$cache0 == null) { Highlighter.< > f__mg$cache0 = new EditorApplication.CallbackFunction(Highlighter.Update); } EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(arg_D8_0, Highlighter.< > f__mg$cache0); Delegate arg_109_0 = EditorApplication.update; if (Highlighter.< > f__mg$cache1 == null) { Highlighter.< > f__mg$cache1 = new EditorApplication.CallbackFunction(Highlighter.Update); } EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(arg_109_0, Highlighter.< > f__mg$cache1); } else { Debug.LogWarning(string.Concat(new string[] { "Item ", text, " not found in window ", windowTitle, "." })); Highlighter.Stop(); } InternalEditorUtility.RepaintAllViews(); } Highlighter.s_RecursionLock = false; } return(flag); }
void DisableInputEvent() { FieldInfo fieldInfo = typeof(EditorApplication).GetField("globalEventHandler", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); appCb -= OnEditorKeyPress; fieldInfo.SetValue(null, appCb); }
public void OnDisable() { System.Reflection.FieldInfo info = typeof(EditorApplication).GetField("globalEventHandler", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); EditorApplication.CallbackFunction value = (EditorApplication.CallbackFunction)info.GetValue(null); value -= HandleDeleteEvent; info.SetValue(null, value); }
private static void OneShotUxmlLiveReload() { try { Dictionary <int, Panel> .Enumerator panelsIterator = UIElementsUtility.GetPanelsIterator(); while (panelsIterator.MoveNext()) { KeyValuePair <int, Panel> current = panelsIterator.Current; HostView hostView = current.Value.ownerObject as HostView; if (hostView != null && hostView.actualView != null) { hostView.Reload(hostView.actualView); } } } catch (Exception exception) { Debug.LogException(exception); } Delegate arg_96_0 = EditorApplication.update; if (RetainedMode.< > f__mg$cache3 == null) { RetainedMode.< > f__mg$cache3 = new EditorApplication.CallbackFunction(RetainedMode.OneShotUxmlLiveReload); } EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(arg_96_0, RetainedMode.< > f__mg$cache3); }
private static void RemoveOnUpdateCallback(EditorApplication.CallbackFunction callback) { RunOnMainThread.Run(delegate { EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, callback); }, true); }
/// <summary> /// Download and install the Unity IAP Package. /// </summary> public void InstallUnityPackage(Action onImport) { if (m_InstallInProgress) { return; } var originalCallback = ServicePointManager.ServerCertificateValidationCallback; // Only OSX supports SSL certificate validation, disable checking on other platforms. // TODO - fix when a Unity Web framework supports SSL. if (Application.platform != RuntimePlatform.OSXEditor) { ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true; } m_InstallInProgress = true; var location = FileUtil.GetUniqueTempPathInProject(); // Extension is required for correct Windows import. location = Path.ChangeExtension(location, ".unitypackage"); UnityWebRequest request = new UnityWebRequest(k_PackageUri, UnityWebRequest.kHttpVerbGET); request.downloadHandler = new DownloadHandlerFile(location); var operation = request.SendWebRequest(); operation.completed += (asyncOp) => { // Installation must be done on the main thread. EditorApplication.CallbackFunction handler = null; handler = () => { ServicePointManager.ServerCertificateValidationCallback = originalCallback; EditorApplication.update -= handler; m_InstallInProgress = false; if ((request.result != UnityWebRequest.Result.ProtocolError) && (request.result != UnityWebRequest.Result.ConnectionError)) { string etag = request.GetResponseHeaders()[k_ETagHeader]; SaveETag(etag); AssetDatabase.ImportPackage(location, false); EditorAnalytics.SendImportServicePackageEvent(new ImportPackageInfo() { packageName = Path.GetFileName(k_PackageUri.ToString()), eTag = etag }); //TODO: ImportPackage is a delayeed operation with no callback. See if we can get a confirmation of successful installation // before firing our callback, or even before Saving the ETag. onImport(); } else { UnityEngine.Debug.LogError(L10n.Tr("Failed to download IAP package. Please check connectivity and retry. Web request Error: ") + request.error); } }; EditorApplication.update += handler; }; }
static VersionHandler() { VersionHandler.VERSION_HANDLER_FILENAME_RE = new Regex(string.Format(".*[\\/]({0})(.*)(\\.dll)$", "Google.VersionHandlerImpl".Replace(".", "\\.")), RegexOptions.IgnoreCase); VersionHandler.typeCache = new Dictionary <string, Type>(); VersionHandler.unityVersionMajorMinor = -1f; if (Environment.CommandLine.Contains("-gvh_disable")) { Debug.Log(string.Format("{0} bootstrap disabled", "Google.VersionHandlerImpl")); } else { Delegate arg_8C_0 = EditorApplication.update; if (VersionHandler.callbackFunction0 == null) { VersionHandler.callbackFunction0 = new EditorApplication.CallbackFunction(VersionHandler.BootStrap); } EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(arg_8C_0, VersionHandler.callbackFunction0); Delegate arg_BD_0 = EditorApplication.update; if (VersionHandler.callbackFunction1 == null) { VersionHandler.callbackFunction1 = new EditorApplication.CallbackFunction(VersionHandler.BootStrap); } EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(arg_BD_0, VersionHandler.callbackFunction1); } }
private static void CheckForFullSdk() { Delegate arg_22_0 = EditorApplication.update; if (NetSDKChecker.f__mgcache2 == null) { NetSDKChecker.f__mgcache2 = new EditorApplication.CallbackFunction(NetSDKChecker.CheckForFullSdk); } EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(arg_22_0, NetSDKChecker.f__mgcache2); if (!NetSDKChecker.checkedSDK) { NetSDKChecker.checkedSDK = true; string[] array = AssetDatabase.FindAssets("Firebase.Database"); bool flag = array != null && array.Length > 0; if (flag && (int)PlayerSettings.apiCompatibilityLevel == 2) { Debug.LogError(DocStrings.DocRef.DotNetSdkMismatch.String()); bool flag2 = EditorUtility.DisplayDialog(DocStrings.DocRef.DotNetSdkMismatchSummary.String(), DocStrings.DocRef.DotNetSdkMismatch.String() + "\n" + DocStrings.DocRef.DotNetSdkChange.String(), DocStrings.Yes, DocStrings.No); if (flag2) { PlayerSettings.apiCompatibilityLevel = ApiCompatibilityLevel.NET_2_0; } } } }
public static void ShowIconSelector(Object targetObj, Rect activatorRect, bool showLabelIcons, OnObjectIconChange onObjectChange) { using (ProfilerSample.Get()) try { var instance = ScriptableObject.CreateInstance(iconSelectorType); var update = new EditorApplication.CallbackFunction(() => { }); instance.InvokeMethod("Init", targetObj, activatorRect, showLabelIcons); update += () => { if (instance) { return; } onObjectChange(GetObjectIcon(targetObj)); EditorApplication.update -= update; }; EditorApplication.update += update; } catch (Exception e) { Debug.LogWarning("Failed to open icon selector\n" + e); } }
public static void UnregisterEditorGlobalInput(EditorApplication.CallbackFunction callback) { System.Reflection.FieldInfo info = typeof(EditorApplication).GetField("globalEventHandler", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); EditorApplication.CallbackFunction value = (EditorApplication.CallbackFunction)info.GetValue(null); value -= callback; info.SetValue(null, value); }
public static void ExecuteFullScreen() { if (EditorApplication.isPlaying) { Debug.Log("SRDisplay GameView cannot be changed in Play Mode"); return; } if (Menu.GetChecked(FullScreenMenuPath)) { SRD.Editor.AsssemblyWrapper.GameView.CloseAllSRDGameView(); Menu.SetChecked(FullScreenMenuPath, false); } else { if (!SRDSettings.LoadScreenRect()) { SRDCorePlugin.ShowMessageBox("Confirm", SRDHelper.SRDMessages.DisplayConnectionError, Debug.LogWarning); return; } if (IsWrongSettings()) { EditorApplication.update += RequestGameViewSize; OnPostClosingTempGameView += SetupGameViewAfterCloseTempGameView; Menu.SetChecked(FullScreenMenuPath, true); return; } SRD.Editor.AsssemblyWrapper.GameView.CloseAllUnityGameView(); SetupGameView(); Menu.SetChecked(FullScreenMenuPath, true); } }
public void OnDisable() { System.Reflection.FieldInfo info = typeof(EditorApplication).GetField("globalEventHandler", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); value -= Shortcuts; info.SetValue(null, value); }
/// <summary> /// Editor上でUnityWebRequestで通信をする /// </summary> public static void EditorSendWebRequest(this UnityWebRequest self, Action onSuccess = null, Action <Exception> onError = null) { self.timeout = timeout; self.SendWebRequest(); EditorApplication.CallbackFunction updateFunc = null; updateFunc = () => { if (self.isDone) { if (self.isHttpError || self.isNetworkError || !string.IsNullOrEmpty(self.error)) { if (onError != null) { onError.Invoke(new Exception(self.error)); } } else { if (onSuccess != null) { onSuccess.Invoke(); } } EditorApplication.update -= updateFunc; return; } }; EditorApplication.update += updateFunc; }
private static void DidReloadScripts() { SetupCryptoKey(); if (EditorApplication.isPlayingOrWillChangePlaymode) { return; } var frameCount = 0; EditorApplication.CallbackFunction reloadTextData = null; reloadTextData = () => { if (frameCount < 30) { frameCount++; return; } Reload(); EditorApplication.update -= reloadTextData; }; EditorApplication.update += reloadTextData; }
private static void EditorInit() { System.Reflection.FieldInfo info = typeof(EditorApplication).GetField("globalEventHandler", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); EditorApplication.CallbackFunction value = (EditorApplication.CallbackFunction)info.GetValue(null); value += EditorGlobalKeyPress; info.SetValue(null, value); }
internal void CleanupEditor() { bool selectAvatarAsset = StageUtility.GetCurrentStageHandle() == StageUtility.GetMainStageHandle(); m_EditMode = EditMode.Stopping; DestroyEditor(); ChangeInspectorLock(m_InspectorLocked); EditorApplication.CallbackFunction CleanUpOnDestroy = null; CleanUpOnDestroy = () => { // Make sure that we restore the "original" selection if we exit Avatar Editing mode // from the avatar tooling itself (e.g by clicking done). if (selectAvatarAsset) { SelectAsset(); } if (!m_CameFromImportSettings) { m_EditMode = EditMode.NotEditing; } EditorApplication.update -= CleanUpOnDestroy; }; EditorApplication.update += CleanUpOnDestroy; // Reset back the Edit Mode specific states (they probably should be better encapsulated) m_GameObject = null; m_ModelBones = null; }
static Startup() { if (!hasInitialized) { hasInitialized = true; EditorApplication.CallbackFunction oldCallback = EditorApplication.playmodeStateChanged; EditorApplication.playmodeStateChanged = delegate { if (!EditorApplication.isPlaying) { DestroyJvm(); FirebaseEditorImpl.Shutdown(); } else { FirebaseEditorImpl.Initialize(); } if (oldCallback != null) { oldCallback.Invoke(); } }; FirebaseEditorImpl.Initialize(); Firebase.Register(new FirebaseEditorImpl.Factory()); } }
//----------------------------------------------------------------------------- // Methods //----------------------------------------------------------------------------- static CustomHierarchyView() { Assembly assembly = Assembly.GetAssembly(typeof(EditorWindow)); Type type = assembly.GetType("UnityEditor.SceneHierarchyWindow"); EditorWindow[] editorWindows = Resources.FindObjectsOfTypeAll <EditorWindow>(); for (int i = 0; i < editorWindows.Length; i++) { if (editorWindows[i].GetType() == type) { CustomHierarchyView.hierarchyWindow = editorWindows[i]; CustomHierarchyView.hierarchyWindow.wantsMouseMove = true; break; } } if (CustomHierarchyView.hierarchyWindow != null) { CustomHierarchyView.hierarchyWindow.Repaint(); EditorApplication.hierarchyWindowItemOnGUI += CustomHierarchyView.OnHierarchyWindowItemOnGUI; } FieldInfo info = typeof(EditorApplication).GetField("globalEventHandler", BindingFlags.Static | BindingFlags.NonPublic); EditorApplication.CallbackFunction value = (EditorApplication.CallbackFunction)info.GetValue(null); value += EditorGlobalKeyPress; info.SetValue(null, value); }
public static void StartBackgroundTask(IEnumerator update, Action end = null) { EditorApplication.CallbackFunction closureCallback = null; closureCallback = () => { try { if (update.MoveNext() == false) { if (end != null) { end(); } EditorApplication.update -= closureCallback; } } catch (Exception ex) { if (end != null) { end(); } Debug.LogException(ex); EditorApplication.update -= closureCallback; } }; EditorApplication.update += closureCallback; }
private static void AdviseUnityActions(EditorPluginModel model, Lifetime connectionLifetime) { var isPlayingAction = new Action(() => { MainThreadDispatcher.Instance.Queue(() => { var isPlayOrWillChange = EditorApplication.isPlayingOrWillChangePlaymode; var isPlaying = isPlayOrWillChange && EditorApplication.isPlaying; if (!model.Play.HasValue() || model.Play.HasValue() && model.Play.Value != isPlaying) { model.Play.SetValue(isPlaying); } var isPaused = EditorApplication.isPaused; if (!model.Pause.HasValue() || model.Pause.HasValue() && model.Pause.Value != isPaused) { model.Pause.SetValue(isPaused); } }); }); isPlayingAction(); // get Unity state model.Play.AdviseNotNull(connectionLifetime, play => { MainThreadDispatcher.Instance.Queue(() => { var res = EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPlaying; if (res != play) { EditorApplication.isPlaying = play; } }); }); model.Pause.AdviseNotNull(connectionLifetime, pause => { MainThreadDispatcher.Instance.Queue(() => { EditorApplication.isPaused = pause; }); }); model.Step.AdviseNotNull(connectionLifetime, x => { MainThreadDispatcher.Instance.Queue(EditorApplication.Step); }); var isPlayingHandler = new EditorApplication.CallbackFunction(() => isPlayingAction()); // left for compatibility with Unity <= 5.5 #pragma warning disable 618 connectionLifetime.AddBracket(() => { EditorApplication.playmodeStateChanged += isPlayingHandler; }, () => { EditorApplication.playmodeStateChanged -= isPlayingHandler; }); #pragma warning restore 618 // new api - not present in Unity 5.5 // private static Action<PauseState> IsPauseStateChanged(UnityModel model) // { // return state => model?.Pause.SetValue(state == PauseState.Paused); // } }
static KeyboardShortcutRegisterer() { bool keyDown = false; EditorApplication.CallbackFunction function = () => { if (!keyDown && Event.current.type == EventType.KeyDown) { keyDown = true; // '_' が入力されたら、Hierarchy で選択しているオブジェクトのアクティブ状態を反転させる if (Event.current.keyCode == KeyCode.Underscore && ToggleGameObjectActiveKeyboardShortcut.IsAvailable()) { ToggleGameObjectActiveKeyboardShortcut.Execute(); } } if (keyDown && Event.current.type == EventType.KeyUp) { keyDown = false; } }; FieldInfo info = typeof(EditorApplication).GetField("globalEventHandler", BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic); EditorApplication.CallbackFunction functions = (EditorApplication.CallbackFunction)info.GetValue(null); functions += function; info.SetValue(null, (object)functions); }
public static void Process() { EditorApplication.contextualPropertyMenu -= onContextualPropertyMenu; EditorApplication.contextualPropertyMenu += onContextualPropertyMenu; EditorApplication.modifierKeysChanged -= onModifierKeysChanged; EditorApplication.modifierKeysChanged += onModifierKeysChanged; EditorApplication.delayCall -= onDelayCall; EditorApplication.delayCall += onDelayCall; EditorApplication.update -= onUpdate; EditorApplication.update += onUpdate; EditorApplication.searchChanged -= onSearchChanged; EditorApplication.searchChanged += onSearchChanged; // globalEventHandler EditorApplication.CallbackFunction function = () => onGlobalEventHandler(Event.current); FieldInfo info = typeof(EditorApplication).GetField("globalEventHandler", BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic); EditorApplication.CallbackFunction functions = (EditorApplication.CallbackFunction)info.GetValue(null); functions += function; info.SetValue(null, (object)functions); //EditorApplication.wantsToQuit -= onQuit; //EditorApplication.wantsToQuit += onQuit; }
private SceneManager() { mUpdateCallback = new EditorApplication.CallbackFunction(EditorUpdate); if (EditorApplication.update == null) { EditorApplication.update += mUpdateCallback; } else if (!EditorApplication.update.Equals(mUpdateCallback)) { EditorApplication.update += mUpdateCallback; } mRefreshThreshold = new TimeSpan(0, 0, 0, SECONDS_TO_WAIT, 0); // We force a config.xml read operation before the SceneManager is used // to avoid inconsistencies on Unity startup. mDoDeserialization = true; // Make sure that the scene is initialized whenever a new instance of // the SceneManager is created. mSceneInitialized = false; // Unity does not allow to store global editor settings in a comfortable // way so we store them in a file. ReadProperties(); }
static API() { var editorAssembly = typeof(EditorWindow).Assembly; containerWindowType = editorAssembly.GetType("UnityEditor.ContainerWindow"); viewType = editorAssembly.GetType("UnityEditor.View"); dockAreaType = editorAssembly.GetType("UnityEditor.DockArea"); parentField = typeof(EditorWindow).GetField("m_Parent", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.Public | BindingFlags.NonPublic); if (dockAreaType != null) { panesField = dockAreaType.GetField("m_Panes", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.Public | BindingFlags.NonPublic); addTabMethod = dockAreaType.GetMethod("AddTab", new System.Type[] { typeof(EditorWindow) }); } if (containerWindowType != null) { windowsField = containerWindowType.GetProperty("windows", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic); mainViewField = containerWindowType.GetProperty("mainView", BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic); } if (viewType != null) allChildrenField = viewType.GetProperty("allChildren", BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo windowsReorderedField = typeof(EditorApplication).GetField("windowsReordered", BindingFlags.Static | BindingFlags.GetField | BindingFlags.Public | BindingFlags.NonPublic); windowsReordered = windowsReorderedField.GetValue(null) as EditorApplication.CallbackFunction; System.Type projectWindowUtilType = editorAssembly.GetType("UnityEditor.ProjectWindowUtil"); if (projectWindowUtilType != null) createAssetMethod = projectWindowUtilType.GetMethod("CreateAsset", new System.Type[] { typeof(Object), typeof(string) }); }
private SceneManager() { mUpdateCallback = new EditorApplication.CallbackFunction(EditorUpdate); if (EditorApplication.update == null) { EditorApplication.update += mUpdateCallback; } else if (!EditorApplication.update.Equals(mUpdateCallback)) { EditorApplication.update += mUpdateCallback; } // We force a config.xml read operation before the SceneManager is used // to avoid inconsistencies on Unity startup. mDoDeserialization = true; // Make sure that the scene is initialized whenever a new instance of // the SceneManager is created. mSceneInitialized = false; }
private static void Internal_CallDelayFunctions() { EditorApplication.CallbackFunction callbackFunction = EditorApplication.delayCall; EditorApplication.delayCall = null; if (callbackFunction != null) { callbackFunction(); } }
private static void CheckCallDelayed() { if ((double) Time.realtimeSinceStartup <= (double) EditorApplication.s_DelayedCallbackTime) return; EditorApplication.update -= new EditorApplication.CallbackFunction(EditorApplication.CheckCallDelayed); EditorApplication.delayedCallback(); }
internal static void CallDelayed(EditorApplication.CallbackFunction function, float timeFromNow) { EditorApplication.delayedCallback = function; EditorApplication.s_DelayedCallbackTime = Time.realtimeSinceStartup + timeFromNow; EditorApplication.update += new EditorApplication.CallbackFunction(EditorApplication.CheckCallDelayed); }
private static void Internal_CallDelayFunctions() { EditorApplication.CallbackFunction delayCall = EditorApplication.delayCall; EditorApplication.delayCall = (EditorApplication.CallbackFunction) null; if (delayCall == null) return; delayCall(); }