Exemple #1
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            AdvancedDropdownItem root = new AdvancedDropdownItem(itemType.Name);

            root.AddChild(new AdvancedDropdownItem("None"));
            root.AddSeparator();

            AdvancedDropdownItem targetParent = root;
            bool multipleCollections          = collections.Count > 1;

            for (int i = 0; i < collections.Count; i++)
            {
                ScriptableObjectCollection collection = collections[i];

                if (multipleCollections)
                {
                    AdvancedDropdownItem collectionParent = new AdvancedDropdownItem(collection.name);
                    root.AddChild(collectionParent);
                    targetParent = collectionParent;
                }

                for (int j = 0; j < collection.Count; j++)
                {
                    ScriptableObjectCollectionItem collectionItem = collection[j];
                    targetParent.AddChild(new CollectionItemDropdownItem(collectionItem));
                }
            }

            if (!multipleCollections)
            {
                root.AddSeparator();
                root.AddChild(new AdvancedDropdownItem(CREATE_NEW_TEXT));
            }
            return(root);
        }
Exemple #2
0
    protected override AdvancedDropdownItem BuildRoot()
    {
        var modes = EnumHelpers.GetValues <GameModeSelection>().Select(x => new
        {
            Mode = x,
            Attr = x.GetAttribute <GameModeAttribute>()
        }).GroupBy(x => x.Attr.MajorEngineVersion);

        var root = new AdvancedDropdownItem("Game");

        foreach (var mode in modes)
        {
            var group = new AdvancedDropdownItem(mode.Key.ToString())
            {
                id = -1
            };

            foreach (var selectionGroup in mode.GroupBy(x => x.Attr.EngineVersion))
            {
                foreach (var selection in selectionGroup)
                {
                    group.AddChild(new AdvancedDropdownItem(selection.Attr.DisplayName)
                    {
                        id = (int)selection.Mode
                    });
                }

                group.AddSeparator();
            }

            root.AddChild(group);
        }

        return(root);
    }
    protected override AdvancedDropdownItem BuildRoot()
    {
        var modes = EnumHelpers.GetValues <Settings.Mode>().Select(x => new {
            Mode     = x,
            Settings = Settings.GetSettings(x)
        }).GroupBy(x => x.Settings.engineVersion);

        var root = new AdvancedDropdownItem("Game");

        foreach (var mode in modes)
        {
            var group = new AdvancedDropdownItem(mode.Key.ToString())
            {
                id = -1
            };

            foreach (var selectionGroup in mode.GroupBy(x => x.Settings.game))
            {
                foreach (var selection in selectionGroup)
                {
                    group.AddChild(new AdvancedDropdownItem(selection.Settings.DisplayName)
                    {
                        id = (int)selection.Mode
                    });
                }

                group.AddSeparator();
            }

            root.AddChild(group);
        }

        return(root);
    }
Exemple #4
0
            public AdvancedDropdownItem GetDropdownItem(AdvancedDropdownItem parent)
            {
                // Draw all the subnamespaces of this namespace level.
                if (namespaceLevels.Count > 0)
                {
                    parent.AddChild(new AdvancedDropdownItem("Namespaces")
                    {
                        enabled = false
                    });
                    foreach (KeyValuePair <string, NamespaceLevel> namespaceLevel in namespaceLevels)
                    {
                        var groupItem = new AdvancedDropdownItem(namespaceLevel.Key);
                        groupItem = namespaceLevel.Value.GetDropdownItem(groupItem);

                        parent.AddChild(groupItem);
                    }
                }

                // Draw all the types of this namespace level.
                idTypePairs.Clear();
                if (types.Any())
                {
                    if (namespaceLevels.Count > 0)
                    {
                        parent.AddSeparator();
                    }

                    parent.AddChild(new AdvancedDropdownItem("Types")
                    {
                        enabled = false
                    });
                    foreach (Type type in types)
                    {
                        var name = type.FullName.Substring(type.FullName.LastIndexOf('.') + 1);
                        if (!type.IsUnitySerializable())
                        {
                            name += " (Not Serializable)";
                        }

                        var dropdownItem = new AdvancedDropdownItem(name);
                        parent.AddChild(dropdownItem);

                        // Use Hash instead of id! If 2 AdvancedDropdownItems have the same name, they will generate the same id (stupid, I know). To ensure searching for a unique identifier, we use the hash instead.
                        idTypePairs.Add(dropdownItem.GetHashCode(), type);
                    }
                }

                return(parent);
            }
Exemple #5
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root = new AdvancedDropdownItem(Name);

            foreach (var m in items)
            {
                if (m == null)
                {
                    root.AddSeparator();
                }
                else
                {
                    root.AddChild(m);
                }
            }

            return(root);
        }
Exemple #6
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            AdvancedDropdownItem root = new AdvancedDropdownItem("Assemblies");
            Dictionary <Group, AdvancedDropdownItem> groupDropdowns = new Dictionary <Group, AdvancedDropdownItem>(new Group.Comparer());

            var allAssemblies = AppDomain.CurrentDomain.GetAssemblies().OrderBy(assembly => assembly.FullName);

            // Populate Unity-compiled assemblies.
            // This includes assemblies in the Assets and Packages directories that are not plugins.
            UAssembly[] assemblies = CompilationPipeline.GetAssemblies();
            Dictionary <string, UAssembly> nameToAssembly = new Dictionary <string, UAssembly>();

            foreach (UAssembly assembly in assemblies)
            {
                nameToAssembly.Add(assembly.name, assembly);
            }

            // Append root locations
            foreach (Location location in Enum.GetValues(typeof(Location)))
            {
                var locationRoot = new AdvancedDropdownItem(location.ToString());
                root.AddChild(locationRoot);
                groupDropdowns.Add(new Group(location), locationRoot);
            }

            foreach (Assembly assembly in allAssemblies)
            {
                Group group = GetGroup(assembly, nameToAssembly);

                Type[]      types         = assembly.GetTypes();
                List <Type> filteredTypes = new List <Type>();
                foreach (Type type in types)
                {
                    bool requirementsMet = true;
                    foreach (Type constraint in constraints)
                    {
                        if (!type.IsSubclassOf(constraint) && type != constraint)
                        {
                            requirementsMet = false;
                        }
                    }

                    foreach (Type requiredInterface in requiredInterfaces)
                    {
                        if (!type.GetInterfaces().Contains(requiredInterface))
                        {
                            requirementsMet = false;
                        }
                    }

                    if (requirementsMet)
                    {
                        filteredTypes.Add(type);
                    }
                }

                if (filteredTypes.Count != 0)
                {
                    if (!groupDropdowns.TryGetValue(group, out AdvancedDropdownItem groupRoot))
                    {
                        groupDropdowns.Add(group, groupRoot = new AdvancedDropdownItem(group.Context));
                        groupDropdowns[new Group(group.Location)].AddChild(groupRoot);
                    }

                    string assemblyName         = assembly.GetName().Name;
                    var    assemblyDropdownItem = new AdvancedDropdownItem(assemblyName);
                    groupRoot.AddChild(assemblyDropdownItem);

                    foreach (Type type in filteredTypes)
                    {
                        assemblyDropdownItem.AddChild(new TypeDropdownItem(type));
                    }
                }
            }

            root.AddSeparator();

            AdvancedDropdownItem initializeOnLoad = new AdvancedDropdownItem("Initialize On Load");

            foreach (Type type in TypeCache.GetTypesWithAttribute <InitializeOnLoadAttribute>())
            {
                initializeOnLoad.AddChild(new TypeDropdownItem(type));
            }

            foreach (MethodInfo method in TypeCache.GetMethodsWithAttribute <InitializeOnLoadMethodAttribute>())
            {
                initializeOnLoad.AddChild(new TypeDropdownItem(method.DeclaringType));
            }

            root.AddChild(initializeOnLoad);

            AdvancedDropdownItem runtimeInitializeOnLoad = new AdvancedDropdownItem("Runtime Initialize On Load");

            foreach (MethodInfo method in TypeCache.GetMethodsWithAttribute <RuntimeInitializeOnLoadMethodAttribute>())
            {
                runtimeInitializeOnLoad.AddChild(new TypeDropdownItem(method.DeclaringType));
            }

            root.AddChild(runtimeInitializeOnLoad);

            return(root);
        }
        protected override AdvancedDropdownItem BuildRoot()
        {
            Child2ParentDict.Clear();

            var root = new AdvancedDropdownItem("地块建筑选择");

            if (m_Instance == null)
            {
                return(root);
            }

            TerrainPieceInfo terrainPieceInfo = m_Instance.m_Scene.GetCurrentTerrainPieceInfo();

            if (terrainPieceInfo == null)
            {
                return(root);
            }

            TerrainMakerDefine.ToolSetting toolSetting = m_Instance.m_Define.Setting;

            List <string> directionList = toolSetting.SceneBuildingDirectionList;

            if (directionList != null && directionList.Count > 0)
            {
                var directionHalf = new AdvancedDropdownItem("文件夹");
                root.AddChild(directionHalf);

                for (int index = 0; index < directionList.Count; index++)
                {
                    string directionPath = directionList[index];

                    DirectoryInfo directoryInfo = new DirectoryInfo("Assets/" + directionPath);
                    FileInfo[]    fileInfos     = directoryInfo.GetFiles();

                    if (fileInfos.Length == 0)
                    {
                        continue;
                    }

                    var directionItem = new AdvancedDropdownItem(directionPath);

                    for (int j = 0; j < fileInfos.Length; j++)
                    {
                        string fileName = fileInfos[j].Name;
                        if (fileName.EndsWith("meta"))
                        {
                            continue;
                        }

                        var fileItem = new AdvancedDropdownItem(fileName);
                        directionItem.AddChild(fileItem);
                        directionItem.AddSeparator();

                        Child2ParentDict.Add(fileName, directionPath);
                    }

                    directionHalf.AddChild(directionItem);
                }
            }

            root.AddSeparator();

            List <string> fileList = toolSetting.SceneBuildingFileList;

            if (fileList != null && fileList.Count > 0)
            {
                var fileHalf = new AdvancedDropdownItem("文件");
                root.AddChild(fileHalf);

                for (int index = 0; index < fileList.Count; index++)
                {
                    string filePath = fileList[index];
                    string fileName = Path.GetFileNameWithoutExtension(filePath);

                    var fileItem = new AdvancedDropdownItem(fileName);
                    fileHalf.AddChild(fileItem);
                    fileHalf.AddSeparator();

                    Child2ParentDict.Add(fileName, IOHelper.GetDirectoryPath(filePath));
                }
            }
            return(root);
        }
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root    = new AdvancedDropdownItem("Depth Slice");
            var allItem = new DepthSliceDropdownItem(ProfileAnalyzer.kDepthAll);

            root.AddChild(allItem);
            if (m_CurrentDepthSliceA == ProfileAnalyzer.kDepthAll && m_CurrentDepthSliceB == ProfileAnalyzer.kDepthAll)
            {
                (m_SelectedIdsFieldInfo.GetValue(m_DataSourceFieldInfo.GetValue(this)) as List <int>).Add(allItem.id);
            }
            var count = m_DepthSliceCountRight == ProfileAnalyzer.kDepthAll ? m_DepthSliceCount :
                        Math.Max(m_DepthSliceCount + Math.Max(0, m_DepthDiff), m_DepthSliceCountRight - Math.Min(0, m_DepthDiff));

            var leftIsMain            = m_DepthDiff < 0;
            var mainThreshold         = leftIsMain ? m_DepthSliceCount : m_DepthSliceCountRight;
            var secondaryMinThreshold = Math.Abs(m_DepthDiff);
            var secondaryMaxThreshold = (leftIsMain ? m_DepthSliceCountRight : m_DepthSliceCount) + secondaryMinThreshold;

            var startIndex = 1;

            for (int i = startIndex; i <= count; i++)
            {
                var selected = false;
                AdvancedDropdownItem child;
                if (m_DepthSliceCountRight != ProfileAnalyzer.kDepthAll)
                {
                    var left  = Mathf.Clamp(i - Math.Max(0, m_DepthDiff), 1, m_DepthSliceCount);
                    var right = Mathf.Clamp(i - Math.Max(0, -m_DepthDiff), 1, m_DepthSliceCountRight);

                    if (m_DepthSliceCount <= 0)
                    {
                        left = -1;
                    }
                    else if (m_DepthSliceCountRight <= 0)
                    {
                        right = -1;
                    }
                    else
                    {
                        // Separators only make sense if there is data on both sides

                        // did we pass the threshold of the main's max depth and started clamping it down?
                        if (i == mainThreshold + 1
                            // ... or the threshold of the secondary's negative depth when adjusted for the depth diff, and stoped clamping it up?
                            || (secondaryMinThreshold != 0 && i == secondaryMinThreshold + 1)
                            // ... or the threshold of the secondary's max depth when adjusted for the depth diff, and started clamping it down?
                            || (i == secondaryMaxThreshold + 1))
                        {
                            root.AddSeparator();
                        }
                    }

                    child    = new DepthSliceDropdownItem(left, right, leftIsMain);
                    selected = m_CurrentDepthSliceA == left && m_CurrentDepthSliceB == right;
                }
                else
                {
                    child    = new DepthSliceDropdownItem(i);
                    selected = m_CurrentDepthSliceA == i;
                }
                root.AddChild(child);
                if (selected)
                {
                    (m_SelectedIdsFieldInfo.GetValue(m_DataSourceFieldInfo.GetValue(this)) as List <int>).Add(child.id);
                }
            }
            return(root);
        }