예제 #1
0
        private static int FindMissingScriptsInHierarchyAndSubjectIndex(MissingScriptDrawer subject, out GameObject[] targetsWithNullComponents)
        {
            for (int s = 0, sceneCount = SceneManager.sceneCount; s < sceneCount; s++)
            {
                var scene = SceneManager.GetSceneAt(s);
                scene.GetAllGameObjects(GetGameObjects);
                for (int g = 0, gameObjectCount = GetGameObjects.Count; g < gameObjectCount; g++)
                {
                    var gameObject = GetGameObjects[g];
                    gameObject.GetComponents(GetComponents);
                    if (GetComponents.Contains(null))
                    {
                        GetGameObjects2.Add(gameObject);
                    }
                    GetComponents.Clear();
                }
                GetGameObjects.Clear();
            }

            targetsWithNullComponents = GetGameObjects2.ToArray();
            GetGameObjects2.Clear();

            var subjectGameObject = subject.gameObject;

            for (int index = targetsWithNullComponents.Length - 1; index >= 0; index--)
            {
                if (targetsWithNullComponents[index] == subjectGameObject)
                {
                    return(index);
                }
            }
            return(-1);
        }
예제 #2
0
        private static bool TryGetPreviousOfType(MissingScriptDrawer subject, out GameObject result)
        {
            GameObject[] gameObjectsWithMissingComponents;
            int          index = FindMissingScriptsInHierarchyAndSubjectIndex(subject, out gameObjectsWithMissingComponents);
            int          count = gameObjectsWithMissingComponents.Length;

            if (count == 0)
            {
                result = null;
                return(false);
            }

            if (index == -1)
            {
                result = gameObjectsWithMissingComponents[0];
            }
            else if (index == 0)
            {
                result = gameObjectsWithMissingComponents[count - 1];
            }
            else
            {
                result = gameObjectsWithMissingComponents[index - 1];
            }
            return(true);
        }
예제 #3
0
        /// <summary> Creates a new instance of the drawer or returns a reusable instance from the pool. </summary>
        /// <param name="parent"> The parent drawers of the created drawers. Can be null. </param>
        /// <param name="inspector"> The inspector in which the IDrawer are contained. Can not be null. </param>
        /// <returns> The drawer instance, ready to be used. </returns>
        public static MissingScriptDrawer Create([NotNull] IParentDrawer parent, [NotNull] IInspector inspector)
        {
            MissingScriptDrawer result;

            if (!DrawerPool.TryGet(out result))
            {
                result = new MissingScriptDrawer();
            }
            result.Setup(ArrayPool <Component> .Create(1), parent, null, inspector);
            result.LateSetup();
            return(result);
        }
예제 #4
0
        public IComponentDrawer GetForComponents(IInspector inspector, Component[] targets, IParentDrawer parent)
        {
            var firstTarget = targets[0];

            if (firstTarget == null)
            {
                return(MissingScriptDrawer.Create(parent, inspector));
            }

            Type customEditorType;
            var  drawerType = GetDrawerTypeForComponent(firstTarget.GetType(), out customEditorType);

            if (typeof(ICustomEditorComponentDrawer).IsAssignableFrom(drawerType))
            {
                return(GetForComponents(drawerType, customEditorType, targets, parent, inspector));
            }

            return(GetForComponents(drawerType, targets, parent, inspector));
        }
예제 #5
0
        private static bool TryGetNextOfType(MissingScriptDrawer subject, out GameObject result)
        {
            GameObject[] gameObjectsWithMissingComponents;
            int          index     = FindMissingScriptsInHierarchyAndSubjectIndex(subject, out gameObjectsWithMissingComponents);
            int          lastIndex = gameObjectsWithMissingComponents.Length - 1;

            if (lastIndex == -1)
            {
                result = null;
                return(false);
            }

            if (index == -1 || index >= lastIndex)
            {
                result = gameObjectsWithMissingComponents[0];
            }
            else
            {
                result = gameObjectsWithMissingComponents[index + 1];
            }
            return(result != subject.Component);
        }