public static GameObjectBoxDrawer Create(IParentDrawer parent, GUIContent label)
        {
            GameObjectBoxDrawer result;

            if (!DrawerPool.TryGet(out result))
            {
                result = new GameObjectBoxDrawer();
            }
            result.Setup(parent, label);
            result.LateSetup();
            return(result);
        }
Esempio n. 2
0
        /// <inheritdoc/>
        protected override void DoBuildMembers()
        {
                        #if DEV_MODE
            Debug.Log(ToString() + ".DoBuildMembers");
                        #endif

            int categoryCount = categorizedBuildList.Count;

            int newMemberCount = categoryCount;

            bool includeAddComponentButton = ShouldIncludeAddComponentButton();
            if (includeAddComponentButton)
            {
                newMemberCount++;
            }

            if (componentsOnlyOnSomeObjectsFound)
            {
                newMemberCount++;
            }

            DrawerArrayPool.Resize(ref members, newMemberCount);

            int index    = 0;
            var readOnly = ReadOnly;
            foreach (var categoryAndComponents in categorizedBuildList)
            {
                var category            = categoryAndComponents.Key;
                var categoryComponents  = categoryAndComponents.Value;
                int categoryMemberCount = categoryComponents.Count;

                if (category.Length == 0)
                {
                    int increaseMemberCount = categoryMemberCount - 1;
                    if (increaseMemberCount > 0)
                    {
                        newMemberCount += increaseMemberCount;
                        DrawerArrayPool.Resize(ref members, newMemberCount);
                    }

                    for (int n = 0; n < categoryMemberCount; n++)
                    {
                        var memberComponents = categoryComponents[n];
                        var componentDrawer  = DrawerProvider.GetForComponents(inspector, memberComponents, this);
                        members[index] = componentDrawer;
                        index++;
                    }
                }
                else
                {
                    var categoryDrawer = CategorizedComponentsDrawer.Create(this, GUIContentPool.Create(category));
                    var setMembers     = DrawerArrayPool.Create(categoryMemberCount);

                    for (int n = 0; n < categoryMemberCount; n++)
                    {
                        var memberComponents = categoryComponents[n];
                        var componentDrawer  = DrawerProvider.GetForComponents(inspector, memberComponents, categoryDrawer);
                        setMembers[n] = componentDrawer;
                    }

                    categoryDrawer.SetMembers(setMembers, true);
                    members[index] = categoryDrawer;
                    index++;
                }
            }

            if (componentsOnlyOnSomeObjectsFound)
            {
                members[index] = GameObjectBoxDrawer.Create(this, GUIContentPool.Create("Components found only on some selected objects can't be multi-edited."));
                index++;
            }

            if (includeAddComponentButton)
            {
                members[index] = AddComponentButtonDrawer.Create(this, inspector);
            }
        }