示例#1
0
    protected void Update()
    {
        if (Application.isPlaying)
        {
            return;
        }

        foreach (GameObject go in Selection.gameObjects)
        {
            if (go == null || PrefabUtility.GetPrefabType(go) == PrefabType.Prefab)
            {
                continue;
            }

            foreach (MonoBehaviour mb in go.GetComponents <MonoBehaviour>())
            {
                IEditorUpdate editorUpdate = mb as IEditorUpdate;

                if (editorUpdate != null)
                {
                    editorUpdate.OnEditorUpdate();
                }
            }
        }
    }
示例#2
0
    protected void OnRenderObject()
    {
        if (Application.isPlaying)
        {
            return;
        }

        if (_monoBehaviours == null)
        {
            _monoBehaviours = new HashSet <MonoBehaviour>();
        }

        if (Selection.gameObjects.Length == 0)
        {
            _monoBehaviours.Clear();
        }
        else
        {
            foreach (GameObject go in Selection.gameObjects)
            {
                if (go == null || PrefabUtility.GetPrefabType(go) == PrefabType.Prefab)
                {
                    continue;
                }

                foreach (MonoBehaviour mb in go.GetComponents <MonoBehaviour>())
                {
                    IEditorUpdate editorUpdate = mb as IEditorUpdate;

                    if (editorUpdate != null)
                    {
                        if (!_monoBehaviours.Contains(mb))
                        {
                            _monoBehaviours.Add(mb);
                            editorUpdate.OnEditorInit();
                        }
                    }
                }
            }
        }
    }