Ejemplo n.º 1
0
        public static IEnumerable <GameObject> FindAll(ExposeToEditorObjectType type, bool roots = true)
        {
            if (SceneManager.GetActiveScene().isLoaded)
            {
                return(FindAllUsingSceneManagement(type, roots));
            }
            List <GameObject> filtered = new List <GameObject>();

            GameObject[] objects = Resources.FindObjectsOfTypeAll <GameObject>();
            for (int i = 0; i < objects.Length; ++i)
            {
                GameObject obj = objects[i] as GameObject;
                if (obj == null)
                {
                    continue;
                }

                if (!obj.IsPrefab())
                {
                    filtered.Add(obj);
                }
            }

            return(filtered.Where(f => IsExposedToEditor(f, type, roots)));
        }
Ejemplo n.º 2
0
        private static bool IsExposedToEditor(GameObject go, ExposeToEditorObjectType type, bool roots)
        {
            ExposeToEditor exposeToEditor = go.GetComponent <ExposeToEditor>();

            return(exposeToEditor != null && (!roots ||
                                              exposeToEditor.transform.parent == null ||
                                              exposeToEditor.transform.parent.GetComponentsInParent <ExposeToEditor>(true).Length == 0) &&
                   !exposeToEditor.MarkAsDestroyed &&
                   exposeToEditor.ObjectType == type &&
                   exposeToEditor.hideFlags != HideFlags.HideAndDontSave);
        }
Ejemplo n.º 3
0
        protected override void ReadFromImpl(object obj)
        {
            base.ReadFromImpl(obj);
            ExposeToEditor uo = (ExposeToEditor)obj;

            Selected     = uo.Selected;
            Unselected   = uo.Unselected;
            BoundsObject = ToID(uo.BoundsObject);
            BoundsType   = uo.BoundsType;
            CustomBounds = uo.CustomBounds;
            CanSelect    = uo.CanSelect;
            CanSnap      = uo.CanSnap;
            AddColliders = uo.AddColliders;
            ObjectType   = uo.ObjectType;
            Colliders    = ToID(uo.Colliders);
        }
Ejemplo n.º 4
0
        public static IEnumerable <GameObject> FindAllUsingSceneManagement(ExposeToEditorObjectType type, bool roots = true)
        {
            List <GameObject> filtered = new List <GameObject>();

            GameObject[] rootGameObjects = SceneManager.GetActiveScene().GetRootGameObjects();
            for (int i = 0; i < rootGameObjects.Length; ++i)
            {
                ExposeToEditor[] exposedObjects = rootGameObjects[i].GetComponentsInChildren <ExposeToEditor>(true);
                for (int j = 0; j < exposedObjects.Length; ++j)
                {
                    ExposeToEditor obj = exposedObjects[j];
                    if (IsExposedToEditor(obj.gameObject, type, roots))
                    {
                        if (!obj.gameObject.IsPrefab())
                        {
                            filtered.Add(obj.gameObject);
                        }
                    }
                }
            }
            return(filtered);
        }
Ejemplo n.º 5
0
        private void Awake()
        {
            RuntimeEditorApplication.IsOpenedChanged += OnEditorIsOpenedChanged;

            m_objectType = ExposeToEditorObjectType.Undefined;

            Init();

            m_hierarchyItem = gameObject.GetComponent <HierarchyItem>();
            if (m_hierarchyItem == null)
            {
                m_hierarchyItem = gameObject.AddComponent <HierarchyItem>();
            }

            if (hideFlags != HideFlags.HideAndDontSave)
            {
                if (Awaked != null)
                {
                    Awaked(this);
                }
            }
        }
Ejemplo n.º 6
0
        private void Awake()
        {
            m_rte = IOC.Resolve <IRTE>();

            m_rte.IsOpenedChanged += OnEditorIsOpenedChanged;

            m_objectType = ExposeToEditorObjectType.Undefined;

            Init();

            m_hierarchyItem = gameObject.GetComponent <HierarchyItem>();
            if (m_hierarchyItem == null)
            {
                m_hierarchyItem = gameObject.AddComponent <HierarchyItem>();
            }

            if (hideFlags != HideFlags.HideAndDontSave)
            {
                if (_Awaked != null)
                {
                    _Awaked(m_rte, this);
                }
            }
        }