Exemple #1
0
        private static void OnClick_Component(int instanceID, Type t)
        {
            bool selected = Selection.activeGameObject == currentGO;

            Selection.activeGameObject = currentGO;

            if (!selected)
            {
                return;
            }

            var check     = currentItem.components[0];
            var checkType = check.GetType();

            if (checkType == t && currentItem.components.Count > 1)
            {
                checkType = currentItem.components[1].GetType();
            }

            bool otherExpanded = HierarchyUtil.IsExpanded(instanceID, checkType);
            bool selfExpanded  = HierarchyUtil.IsExpanded(instanceID, t);

            if (!selfExpanded || !selected)
            {
                HierarchyUtil.FocusComponent(instanceID, t);
            }
            else if (!otherExpanded)
            {
                HierarchyUtil.ExpandComponents(instanceID, true);
            }
            else
            {
                HierarchyUtil.FocusComponent(instanceID, t);
            }
        }