EndScrollView() public static method

Ends a scrollview started with a call to BeginScrollView.

public static EndScrollView ( ) : void
return void
示例#1
0
            public override void OnGUI(Rect rect)
            {
                searchText = searchField.OnGUI(searchText);

                scrollPosition = EGL.BeginScrollView(scrollPosition);

                foreach (var type in behaviourTypes)
                {
                    if (type.ToLower().Contains(searchText.ToLower()))
                    {
                        EGL.BeginHorizontal();
                        EGL.LabelField(type, GL.Width(140));
                        if (GL.Button("Add", GL.Width(40)))
                        {
                            var instance = (StateBehaviour)ScriptableObject.CreateInstance(type);
                            instance.name      = type;
                            instance.hideFlags = HideFlags.HideInHierarchy;
                            list.Add(instance);

                            AssetDatabase.AddObjectToAsset(instance, profile);
                            AssetDatabase.SaveAssets();

                            editorWindow.Close();
                        }
                        EGL.EndHorizontal();
                    }
                }

                EGL.EndScrollView();
            }
示例#2
0
        private void OnGUI()
        {
            if (EntityManager == null)
            {
                EditorGUILayout.HelpBox("please set EntityManager -> BuffDebugWindow.EntityManager",
                                        MessageType.Warning);
                return;
            }

            var entitys = EntityManager.Entitys;

            EditorGUILayout.LabelField("Entity count:" + entitys.Count);

            EditorGUI.indentLevel++;
            _pos = EditorGUILayout.BeginScrollView(_pos, "box");
            {
                foreach (var entity in entitys)
                {
                    EditorGUILayout.LabelField($"{entity} Buff Count:" +
                                               EntityManager.GetAllBuff(entity).Count());
                }
            }
            EditorGUILayout.EndScrollView();
            EditorGUI.indentLevel--;

            Repaint();
        }
    void ShowSettings()
    {
        LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance;
        ImporterConfiguration   importCfg       = editorUtilities.ImportCfg;

        EGL.BeginVertical();
        {
            EGL.Separator();

            GUILayout.Label("LOD Levels");

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                if (importCfg.LodLevels.Count >= 4)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Button("Add LOD Level"))
                {
                    importCfg.LodLevels.Add(new LodLevel());
                    importCfg.IsDirty = true; // Todo: Nasty
                }
                GUI.enabled = true;

                // Show the list of LODS
                EGL.BeginVertical();
                {
                    _lodScrollPos = EGL.BeginScrollView(_lodScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height));
                    {
                        var removeThese = new List <LodLevel>();
                        int i           = 0;
                        foreach (LodLevel lod in importCfg.LodLevels)
                        {
                            if (ShowLodLevel(lod, i))
                            {
                                removeThese.Add(lod);
                                importCfg.IsDirty = true; // Nasty
                            }
                            i++;
                        }
                        foreach (LodLevel lod in removeThese)
                        {
                            importCfg.LodLevels.Remove(lod);
                        }
                    }
                    EGL.EndScrollView();
                }
                EGL.EndVertical();

                EGL.Space();

                GUILayout.Label("Control how many assets are processed in one go.");
                importCfg.BatchLimit = EGL.IntField("Batch limit", importCfg.BatchLimit);
                GUILayout.Label("Larger batches mean faster processing but require\nmore memory. Change this with care, or Unity's\nmemory might run out!");
            }
            EGL.EndVertical();
        }
        EGL.EndVertical();
    }
    void OnGUI()
    {
        LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance;

        if (editorUtilities == null)
        {
            GUILayout.Label("No running instance of LandmassImporter found");
            return;
        }

        if (editorUtilities.IsProcessing)
        {
            ShowProgressBar();
        }

        GUI.enabled = !editorUtilities.IsProcessing;

        EGL.BeginVertical();
        {
            EGL.Separator();

            _currentState = (MenuState)GUILayout.Toolbar((int)_currentState, menuTitles);

            EGL.BeginHorizontal();
            {
                _globalScrollPos = EGL.BeginScrollView(_globalScrollPos, GuiUtils.Skin.box);
                {
                    EGL.BeginVertical();
                    {
                        EGL.Separator();

                        _menus[_currentState]();
                        GUILayout.FlexibleSpace();

                        EGL.Separator();
                    }
                    EGL.EndVertical();
                }
                EGL.EndScrollView();
            }
            EGL.EndHorizontal();

            EGL.Separator();

            ShowSaveButtons();

            GUILayout.Space(16);
        }
        EGL.EndVertical();

        GUI.enabled = true;
    }
示例#5
0
        public void OnGUI()
        {
            if (data != null)
            {
                scroll = UGL.BeginScrollView(scroll, EditorStyles.helpBox);
                UGL.BeginHorizontal(EditorStyles.miniButton);
                type      = (DataTypes)GUILayout.Toolbar((int)type, System.Enum.GetNames(typeof(DataTypes)));
                GUI.color = Color.green;
                if (GUILayout.Button("+"))
                {
                    data.Add(type, string.Empty);
                }
                GUI.color = Color.white;
                UGL.EndHorizontal();
                switch (type)
                {
                case DataTypes.Color:
                    ColorGUI();
                    break;

                case DataTypes.Float:
                    FloatGUI();
                    break;

                case DataTypes.Texture:
                    TextureGUI();
                    break;

                case DataTypes.Vector:
                    VectorGUI();
                    break;
                }
                UGL.EndScrollView();
                //UGL.EndVertical();
                if (data != null)
                {
                    data.SetValues();
                }
            }
        }
        void DrawConsentDialogContentEditor()
        {
            // TextEditor for selecting and editing portions of text.
            TextEditor textEditor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
            SP         dialog     = PrivacyProperties.consentDialogContent.property;

            /// Fix error that make indexes reset to 0 when lose focus.
            int startIndex, endIndex;

            FixIndexesResetError(textEditor, out startIndex, out endIndex);

            // TextEditor inherently requires GUILayout.TextArea which doesn't work with copy & paste.
            // To enable copy & paste we'll need to use EditorGUILayout.TextArea which will make
            // text selection unavailable.
            // Since we can't have both things at the same time, we need a toggle to switch between them.
            EnableCopyPasteMode = EGL.ToggleLeft(PrivacyProperties.enableCopyPasteMode.content, EnableCopyPasteMode);

            /// These functions are not available when enabling copy & paste.
            if (!EnableCopyPasteMode)
            {
                EGL.BeginHorizontal();

                EGL.BeginHorizontal(ES.helpBox);
                DrawHyperlinkButton(textEditor.SelectedText, startIndex, endIndex);
                DrawEditButtons(textEditor.SelectedText, dialog, startIndex, endIndex);
                EGL.EndHorizontal();

                // Draw insert toggle dropdown.
                DrawInsertDropdown(dialog, endIndex, textEditor, "ToggleDropdown",
                                   DefaultConsentDialog.GetAllToggleIds(), "Insert Toggle", ConsentDialog.TogglePattern,
                                   () => SelectedToggleIndex, param => SelectedToggleIndex = param);

                // Draw insert button dropwdown.
                DrawInsertDropdown(dialog, endIndex, textEditor, "ButtonDropDown",
                                   DefaultConsentDialog.GetAllButtonIds(), "Insert Button", ConsentDialog.ButtonPattern,
                                   () => SelectedButtonIndex, param => SelectedButtonIndex = param);

                EGL.EndHorizontal();
            }
            else
            {
                EGL.Space();
            }

            DrawHyperLinkInputSection(dialog);

            /// We need to do this because GUILayout.TextArea, the only TextArea that work with TextEditor, doesn't work with copy & paste.
            GUIStyle style = new GUIStyle(ES.textArea)
            {
                wordWrap = true
            };

            mainContentTextAreaScroll = GUILayout.BeginScrollView(mainContentTextAreaScroll,
                                                                  false, false, GUILayout.Height(EditorGUIUtility.singleLineHeight * 10));

            GUI.SetNextControlName(textAreaControlName);
            dialog.stringValue = EnableCopyPasteMode ?
                                 EGL.TextArea(dialog.stringValue, style, GUILayout.ExpandHeight(true)) :
                                 GUILayout.TextArea(dialog.stringValue, style, GUILayout.ExpandHeight(true));

            EGL.EndScrollView();
        }
    void ShowTreemaps()
    {
        LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance;
        ImporterConfiguration   importCfg       = editorUtilities.ImportCfg;

        EGL.BeginVertical();
        {
            GUILayout.Label("The settings for processing tree maps.");

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Postfix for treemap files.");
                importCfg.TreemapTag = EGL.TextField("Name postfix", importCfg.TreemapTag);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Treemap file specifications. Please use x^2.");
                importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("The prototypes to assign. (Current count: " + editorUtilities.TreePrototypes.Count + ")");

                EGL.Separator();

                EGL.BeginHorizontal();
                {
                    if (editorUtilities.TreePrototypes.Count >= 8)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Add Prototype"))
                    {
                        editorUtilities.TreePrototypes.Add(new TreePrototype());
                        importCfg.IsDirty = true; // Todo: Nasty
                    }
                    GUI.enabled = true;
                }
                EGL.EndHorizontal();

                // Show the list
                EGL.BeginVertical();
                {
                    _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height));
                    {
                        List <TreePrototype> removeThese = new List <TreePrototype>();
                        int i = 0;
                        foreach (TreePrototype prototype in editorUtilities.TreePrototypes)
                        {
                            if (ShowTreePrototype(prototype, i))
                            {
                                removeThese.Add(prototype);
                                importCfg.IsDirty = true; // Nasty
                            }
                            i++;
                        }
                        foreach (TreePrototype prototype in removeThese)
                        {
                            editorUtilities.TreePrototypes.Remove(prototype);
                        }
                    }
                    EGL.EndScrollView();
                }
                EGL.EndVertical();
            }
            EGL.EndVertical();
        }
        EGL.EndVertical();
    }
    void ShowDetailMaps()
    {
        LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance;
        ImporterConfiguration   importCfg       = editorUtilities.ImportCfg;

        EGL.BeginVertical();
        {
            GUILayout.Label("The settings for processing detail maps.");

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Postfix for detailmap files.");
                importCfg.SplatmapTag = EGL.TextField("Name postfix", importCfg.SplatmapTag);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Splatmap file specifications. Please use x^2.");
                importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention);
                importCfg.SplatmapFlipX     = EGL.Toggle("Mirror X", importCfg.SplatmapFlipX);
                importCfg.SplatmapFlipY     = EGL.Toggle("Mirror Y", importCfg.SplatmapFlipY);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("The textures to assign. (Current count: " + editorUtilities.DetailPrototypes.Count + ")");

                EGL.Separator();

                EGL.BeginHorizontal();
                {
                    if (editorUtilities.DetailPrototypes.Count >= 8)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Add Prototype"))
                    {
                        editorUtilities.DetailPrototypes.Add(new DetailPrototype());
                        importCfg.IsDirty = true; // Todo: Nasty, because the above prototypes still need to be converted to a serializable format, which is not directly done here
                    }
                    GUI.enabled = true;
                }
                EGL.EndHorizontal();

                // Show the list
                EGL.BeginVertical();
                {
                    _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height));
                    {
                        List <DetailPrototype> removeThese = new List <DetailPrototype>();
                        int i = 0;
                        foreach (DetailPrototype prototype in editorUtilities.DetailPrototypes)
                        {
                            if (ShowDetailPrototype(prototype, i))
                            {
                                removeThese.Add(prototype);
                                importCfg.IsDirty = true; // Nasty
                            }
                            i++;
                        }
                        foreach (DetailPrototype prototype in removeThese)
                        {
                            editorUtilities.DetailPrototypes.Remove(prototype);
                        }
                    }
                    EGL.EndScrollView();
                }
                EGL.EndVertical();
            }
            EGL.EndVertical();
        }
        EGL.EndVertical();
    }
    void ShowSplatmaps()
    {
        LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance;
        ImporterConfiguration   importCfg       = editorUtilities.ImportCfg;

        EGL.BeginVertical();
        {
            GUILayout.Label("The settings for processing splatmaps.");

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Postfix for splatmap files.");
                importCfg.SplatmapTag = EGL.TextField("Name postfix", importCfg.SplatmapTag);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Splatmap file specifications. Please use x^2.");
                importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention);
                importCfg.SplatmapFlipX     = EGL.Toggle("Mirror X", importCfg.SplatmapFlipX);
                importCfg.SplatmapFlipY     = EGL.Toggle("Mirror Y", importCfg.SplatmapFlipY);
                importCfg.TrimEmptyChannels = EGL.Toggle("Trim empty", importCfg.TrimEmptyChannels);
                importCfg.NormalizationMode = (NormalizationMode)EditorGUILayout.EnumPopup("Normalize mode", importCfg.NormalizationMode);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("The textures to assign. (Current count: " + editorUtilities.SplatPrototypes.Count + ")");

                EGL.Separator();

                EGL.BeginHorizontal();
                {
                    if (editorUtilities.SplatPrototypes.Count >= 8)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Add Prototype"))
                    {
                        editorUtilities.SplatPrototypes.Add(new SplatPrototype());
                        importCfg.IsDirty = true; // Todo: Nasty
                    }
                    GUI.enabled = true;

                    if (GUILayout.Button("Grab from Selected Terrain Object or Asset"))
                    {
                        GetPrototypesFromSelectedTerrain();
                        importCfg.IsDirty = true; // Todo: Nasty
                    }
                }
                EGL.EndHorizontal();

                // Show the list
                EGL.BeginVertical();
                {
                    _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height));
                    {
                        List <SplatPrototype> removeThese = new List <SplatPrototype>();
                        int i = 0;
                        foreach (SplatPrototype splatPrototype in editorUtilities.SplatPrototypes)
                        {
                            if (ShowSplatPrototype(splatPrototype, i))
                            {
                                removeThese.Add(splatPrototype);
                                importCfg.IsDirty = true; // Nasty
                            }
                            i++;
                        }
                        foreach (SplatPrototype splatPrototype in removeThese)
                        {
                            editorUtilities.SplatPrototypes.Remove(splatPrototype);
                        }
                    }
                    EGL.EndScrollView();
                }
                EGL.EndVertical();
            }
            EGL.EndVertical();
        }
        EGL.EndVertical();
    }
示例#10
0
    private void OnGUI()
    {
        UG.BeginVertical();

        UG.BeginHorizontal();
        UG.LabelField("当前数据源:" + (_dataPath.IsNullPath() ? "未在本地保存,已编辑内容随时可能丢失!" : _dataPath));
        if (GUILayout.Button("选择"))
        {
            string path = EditorUtility.OpenFilePanelWithFilters("选择数据源文件", Application.dataPath + "/Hotassets/Data", new [] { "text", "txt" });
            if (!string.IsNullOrEmpty(path))
            {
                Dictionary <string, List <InterlocutionData> > temperData = null;
                try {
                    temperData = JsonConvert.DeserializeObject <Dictionary <string, List <InterlocutionData> > >(File.ReadAllText(path));
                } catch (JsonException) {
                    temperData = _data;
                    path       = _dataPath;
                    EditorApplication.Beep();
                    EditorUtility.DisplayDialog("异常捕获!", "数据源文件不能被正确加载,请确定.json文件的有效性", "知道了");
                } finally {
                    _data     = temperData;
                    _dataPath = path;
                }
            }
        }

        UG.EndHorizontal();

        UG.BeginHorizontal();

        int subject = UG.Popup("所属学科", _editingSubject, InterlocutionData.Keys);

        if (subject != _editingSubject)
        {
            _editingInterlocution = -1;
        }
        _editingSubject = subject;
        string key = InterlocutionData.Keys[_editingSubject];

        UG.LabelField("分组", _editingSubject != InterlocutionData.Keys.Length - 1 ? Subject.ToSubject(InterlocutionData.Keys[_editingSubject]).group.ToString() : "无");

        UG.EndHorizontal();

        _scrollPostion = UG.BeginScrollView(_scrollPostion);

        if (!_data.ContainsKey(key))
        {
            _data[key] = new List <InterlocutionData>();
        }
        List <InterlocutionData> interlocutions = _data[key];

        int _deletedInterlocution = -1;

        UG.LabelField("[已有 " + interlocutions.Count + " 道问答]");
        for (int i = 0, l = interlocutions.Count; i < l; i++)
        {
            UG.BeginHorizontal();

            UG.LabelField("[Q " + i + "] " + interlocutions[i].question);
            if (GUILayout.Button("编辑"))
            {
                _editingInterlocution = i;
            }

            if (GUILayout.Button("删除"))
            {
                EditorApplication.Beep();
                if (EditorUtility.DisplayDialog("危险操作警告⚠️", "即将删除问答 [Q" + i + "] (该操作不可逆)", "确认", "取消"))
                {
                    _deletedInterlocution = i;
                    if (_editingInterlocution == _deletedInterlocution)
                    {
                        _editingInterlocution = -1;
                    }
                }
            }

            UG.EndHorizontal();
        }

        if (_deletedInterlocution != -1)
        {
            interlocutions.RemoveAt(_deletedInterlocution);
        }

        UG.EndScrollView();

        if (GUILayout.Button("添加问答"))
        {
            _editingInterlocution = interlocutions.Count;
            interlocutions.Add(new InterlocutionData());
        }

        UG.LabelField("问答编辑区");
        if (_editingInterlocution != -1)
        {
            UG.LabelField("Q " + _editingInterlocution);
            InterlocutionData interlocution = interlocutions[_editingInterlocution];
            interlocution.question = UG.TextArea(interlocution.question);
            interlocution.answer   = (Option)UG.EnumPopup("正确选项", interlocution.answer);
            UG.LabelField("选项A");
            interlocution.optionA = UG.TextArea(interlocution.optionA);
            UG.LabelField("选项B");
            interlocution.optionB = UG.TextArea(interlocution.optionB);
            UG.LabelField("选项C");
            interlocution.optionC = UG.TextArea(interlocution.optionC);
            UG.LabelField("选项D");
            interlocution.optionD = UG.TextArea(interlocution.optionD);
        }
        else
        {
            UG.HelpBox("需要选择一个问答进行编辑!", MessageType.Warning);
        }

        if (GUILayout.Button("保存"))
        {
            bool toSave   = true;
            bool toImport = false;
            if (_dataPath.IsNullPath())
            {
                string path = EditorUtility.SaveFilePanel("保存问答数据", Application.dataPath + "/Hotassets/Data", "InterlocutionData", "txt");
                if (string.IsNullOrEmpty(path))
                {
                    toSave = false;
                }
                else
                {
                    _dataPath = path;
                    toImport  = true;
                }
            }

            if (toSave)
            {
                File.WriteAllText(_dataPath, JsonConvert.SerializeObject(_data));
                EditorPrefs.SetString(DATA_SAVE_PATH, _dataPath);
            }

            if (toImport)
            {
                AssetDatabase.ImportAsset(_dataPath.Substring(_dataPath.IndexOf("Assets")));
            }
        }

        UG.EndVertical();
    }
示例#11
0
    void OnGUI()
    {
        //This is used for debugging, when the code is changed, simply refocussing the City Generator window will reload the code
        if (window == null)
        {
            OpenWindow();
        }
        scrollLocation = EGL.BeginScrollView(scrollLocation);

        GL.BeginHorizontal();
        GL.Label("Procedural City Generator", EditorStyles.boldLabel);
        GL.Space(50);
        EGL.BeginHorizontal("Box");
        rDebugToggle.target = EGL.ToggleLeft("Debug Mode?", rDebugToggle.target);
        EGL.EndHorizontal();
        GL.EndHorizontal();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        showTerrainGUI();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        showPopulationMapGUI();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        showGrowthMapGUI();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        showRoadMapGUI();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        showBuildingGUI();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        if (GL.Button("Reset"))
        {
            oldShowPop          = false;
            oldShowGrowth       = false;
            showTerrainUI       = true;
            showPopUI           = false;
            showGrowthUI        = false;
            showRoadMapAdvanced = false;
            showRoadMapUI       = false;
            showBuildingUI      = false;
            terrainGenerated    = false;
            populationGenerated = false;
            growthMapGenerated  = false;
            roadMapGenerated    = false;
            roadMeshGenerated   = false;

            terrainLabel    = "1. Terrain Generation - NOT COMPLETED ✘";
            populationLabel = "2. Population Map Generation - NOT COMPLETED ✘";
            growthLabel     = "3. Growth Map Generation - NOT COMPLETED ✘";
            roadmapLabel    = "4. Road Map Generation - NOT COMPLETED ✘";
            buildingLabel   = "5. Building Generation - NOT COMPLETED ✘";
        }

        // TESTING

        /*
         * if (GL.Button ("Generate Houses")) {
         *      generator.testHouses ();
         * }*/
        //END TESTING

        EGL.EndScrollView();
    }
示例#12
0
 public void Dispose()
 {
     EGL.EndScrollView();
 }
示例#13
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            using (new EditorGUI.DisabledScope(false))
            {
                var isManagedPlugin = importers.All(x => x.dllType == DllType.ManagedNET35 || x.dllType == DllType.ManagedNET40);
                if (isManagedPlugin)
                {
                    ShowReferenceOptions();
                    GUILayout.Space(10f);
                }

                GUILayout.Label(Styles.kPluginPlatforms, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                ShowGeneralOptions();
                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                if (IsEditingPlatformSettingsSupported())
                {
                    ShowPlatformSettings();
                }

                if (isManagedPlugin)
                {
                    GUILayout.Label(Styles.kDefineConstraints, EditorStyles.boldLabel);

                    if (m_DefineConstraints.list.Count > 0)
                    {
                        var defines = InternalEditorUtility.GetCompilationDefines(EditorScriptCompilationOptions.BuildingForEditor, EditorUserBuildSettings.activeBuildTargetGroup, EditorUserBuildSettings.activeBuildTarget);

                        var defineConstraintsCompatible = true;

                        if (defines != null)
                        {
                            for (var i = 0; i < m_DefineConstraints.list.Count && defineConstraintsCompatible; ++i)
                            {
                                var defineConstraint = ((DefineConstraint)m_DefineConstraints.list[i]).name;

                                if (DefineConstraintsHelper.GetDefineConstraintCompatibility(defines, defineConstraint) != DefineConstraintsHelper.DefineConstraintStatus.Compatible)
                                {
                                    defineConstraintsCompatible = false;
                                }
                            }

                            var constraintValidityRect = new Rect(GUILayoutUtility.GetLastRect());
                            constraintValidityRect.x = constraintValidityRect.width - Styles.kValidityIconWidth / 4;
                            var image   = defineConstraintsCompatible ? Styles.validDefineConstraint : Styles.invalidDefineConstraint;
                            var tooltip = Styles.GetTitleTooltipFromDefineConstraintCompatibility(defineConstraintsCompatible);
                            var content = new GUIContent(image, tooltip);

                            constraintValidityRect.width  = Styles.kValidityIconWidth;
                            constraintValidityRect.height = Styles.kValidityIconHeight;
                            EditorGUI.LabelField(constraintValidityRect, content);
                        }
                    }

                    m_DefineConstraints.DoLayoutList();
                }

                if (importers.All(imp => imp.isNativePlugin))
                {
                    GUILayout.Space(10f);
                    GUILayout.Label(Styles.kLoadSettings, EditorStyles.boldLabel);
                    ShowLoadSettings();
                }
            }

            serializedObject.ApplyModifiedProperties();

            ApplyRevertGUI();

            // Don't output additional information if we have multiple plugins selected
            if (targets.Length > 1)
            {
                return;
            }

            GUILayout.Label(Styles.kInformation, EditorStyles.boldLabel);

            m_InformationScrollPosition = EditorGUILayout.BeginVerticalScrollView(m_InformationScrollPosition);

            foreach (var prop in m_PluginInformation)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(prop.Key, GUILayout.Width(85));
                EditorGUILayout.SelectableLabel(prop.Value, GUILayout.Height(EditorGUI.kSingleLineHeight));
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.EndScrollView();
            GUILayout.FlexibleSpace();

            // Warning for Case 648027
            // Once Mono loads a native plugin, it never releases a handle, thus plugin is never unloaded.
            if (importer.isNativePlugin)
            {
                EditorGUILayout.HelpBox("Once a native plugin is loaded from script, it's never unloaded. If you deselect a native plugin and it's already loaded, please restart Unity.", MessageType.Warning);
            }
        }
示例#14
0
        private void OnGUI()
        {
            EditorGUIUtility.labelWidth = (float)Screen.width - 64f - 20f;
            bool flag = true;

            this.m_ScrollPosition = EditorGUILayout.BeginVerticalScrollView(this.m_ScrollPosition, false, GUI.skin.verticalScrollbar, GUI.skin.scrollView, new GUILayoutOption[0]);
            flag &= this.ValidateTerrain();
            EditorGUI.BeginChangeCheck();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            string label           = string.Empty;
            float  alignmentOffset = 0f;

            switch (this.m_Terrain.materialType)
            {
            case Terrain.MaterialType.BuiltInStandard:
                if (this.m_Terrain.useDefaultSmoothness)
                {
                    label = "\n Albedo (RGB)";
                }
                else
                {
                    label = " Albedo (RGB)\nSmoothness (A)";
                }
                alignmentOffset = 15f;
                break;

            case Terrain.MaterialType.BuiltInLegacyDiffuse:
                label           = "\n Diffuse (RGB)";
                alignmentOffset = 15f;
                break;

            case Terrain.MaterialType.BuiltInLegacySpecular:
                label           = "Diffuse (RGB)\n   Gloss (A)";
                alignmentOffset = 12f;
                break;

            case Terrain.MaterialType.Custom:
                label           = " \n  Splat";
                alignmentOffset = 0f;
                break;
            }
            TerrainSplatEditor.TextureFieldGUI(label, ref this.m_Texture, alignmentOffset);
            TerrainSplatEditor.TextureFieldGUI("\nNormal", ref this.m_NormalMap, -4f);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            flag &= this.ValidateMainTexture(this.m_Texture);
            if (flag)
            {
                if (TerrainSplatEditor.IsUsingMetallic(this.m_Terrain.materialType, this.m_Terrain.materialTemplate))
                {
                    EditorGUILayout.Space();
                    float labelWidth = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 60f;
                    this.m_Metallic             = EditorGUILayout.Slider("Metallic", this.m_Metallic, 0f, 1f, new GUILayoutOption[0]);
                    EditorGUIUtility.labelWidth = labelWidth;
                }
                else
                {
                    if (TerrainSplatEditor.IsUsingSpecular(this.m_Terrain.materialType, this.m_Terrain.materialTemplate))
                    {
                        this.m_Specular = EditorGUILayout.ColorField("Specular", this.m_Specular, new GUILayoutOption[0]);
                    }
                }
            }
            TerrainSplatEditor.SplatSizeGUI(ref this.m_TileSize, ref this.m_TileOffset);
            bool flag2 = EditorGUI.EndChangeCheck();

            EditorGUILayout.EndScrollView();
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUI.enabled = flag;
            if (GUILayout.Button(this.m_ButtonTitle, new GUILayoutOption[]
            {
                GUILayout.MinWidth(100f)
            }))
            {
                this.ApplyTerrainSplat();
                base.Close();
                GUIUtility.ExitGUI();
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();
            if (flag2 && flag && this.m_Index != -1)
            {
                this.ApplyTerrainSplat();
            }
        }
 public void OnGUI(int windowID)
 {
     if (this.m_LookDevView != null)
     {
         List <CubemapInfo> hdriList = this.m_LookDevView.envLibrary.hdriList;
         bool flag = (146f * hdriList.Count) > this.m_PositionInLookDev.height;
         if (flag)
         {
             this.m_ScrollPosition = EditorGUILayout.BeginScrollView(this.m_ScrollPosition, new GUILayoutOption[0]);
         }
         else
         {
             this.m_ScrollPosition = new Vector2(0f, 0f);
         }
         if (hdriList.Count == 1)
         {
             Color color = GUI.color;
             GUI.color = Color.gray;
             Vector2 vector   = GUI.skin.label.CalcSize(styles.sDragAndDropHDRIText);
             Rect    position = new Rect((this.m_PositionInLookDev.width * 0.5f) - (vector.x * 0.5f), (this.m_PositionInLookDev.height * 0.5f) - (vector.y * 0.5f), vector.x, vector.y);
             GUI.Label(position, styles.sDragAndDropHDRIText);
             GUI.color = color;
         }
         for (int i = 0; i < hdriList.Count; i++)
         {
             Rect        rect5;
             Rect        rect6;
             CubemapInfo infos       = hdriList[i];
             ShadowInfo  shadowInfo  = infos.shadowInfo;
             int         intProperty = this.m_LookDevView.config.GetIntProperty(LookDevProperty.HDRI, LookDevEditionContext.Left);
             int         num3        = this.m_LookDevView.config.GetIntProperty(LookDevProperty.HDRI, LookDevEditionContext.Right);
             if ((this.m_LookDevView.config.lookDevMode == LookDevMode.Single1) || (this.m_LookDevView.config.lookDevMode == LookDevMode.Single2))
             {
                 num3 = -1;
             }
             bool     flag2 = (i == intProperty) || (i == num3);
             Color    black = Color.black;
             Color    firstViewGizmoColor = Color.black;
             GUIStyle miniLabel           = EditorStyles.miniLabel;
             if (flag2)
             {
                 if (i == intProperty)
                 {
                     black = (Color)LookDevView.m_FirstViewGizmoColor;
                     firstViewGizmoColor = (Color)LookDevView.m_FirstViewGizmoColor;
                     miniLabel           = styles.sLabelStyleFirstContext;
                 }
                 else if (i == num3)
                 {
                     black = (Color)LookDevView.m_SecondViewGizmoColor;
                     firstViewGizmoColor = (Color)LookDevView.m_SecondViewGizmoColor;
                     miniLabel           = styles.sLabelStyleSecondContext;
                 }
                 if (intProperty == num3)
                 {
                     black = (Color)LookDevView.m_FirstViewGizmoColor;
                     firstViewGizmoColor = (Color)LookDevView.m_SecondViewGizmoColor;
                     miniLabel           = styles.sLabelStyleBothContext;
                 }
             }
             GUILayoutOption[] optionArray1 = new GUILayoutOption[] { GUILayout.Width(250f) };
             GUILayout.BeginVertical(optionArray1);
             int num4 = hdriList.FindIndex(x => x == this.m_SelectedCubemapInfo);
             if ((((this.m_SelectedCubemap != null) || this.m_DragBeingPerformed) && this.GetInsertionRect(i).Contains(Event.current.mousePosition)) && ((((num4 - i) != 0) && ((num4 - i) != -1)) || (num4 == -1)))
             {
                 GUILayout.Label(GUIContent.none, styles.sSeparatorStyle, new GUILayoutOption[0]);
                 GUILayoutUtility.GetRect((float)250f, (float)16f);
             }
             GUILayout.Label(GUIContent.none, styles.sSeparatorStyle, new GUILayoutOption[0]);
             GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(250f), GUILayout.Height(18f) };
             GUILayout.BeginHorizontal(optionArray2);
             StringBuilder builder = new StringBuilder();
             builder.Append(i.ToString());
             builder.Append(" - ");
             builder.Append(infos.cubemap.name);
             GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Height(18f), GUILayout.MaxWidth(175f) };
             GUILayout.Label(builder.ToString(), miniLabel, optionArray3);
             GUILayout.FlexibleSpace();
             if (GUILayout.Button(styles.sEnvControlIcon, LookDevView.styles.sToolBarButton, new GUILayoutOption[0]))
             {
                 PopupWindow.Show(GUILayoutUtility.topLevel.GetLast(), new EnvSettingsWindow(this.m_LookDevView, infos));
                 GUIUtility.ExitGUI();
             }
             using (new EditorGUI.DisabledScope(infos.cubemap == LookDevResources.m_DefaultHDRI))
             {
                 if (GUILayout.Button(styles.sCloseIcon, LookDevView.styles.sToolBarButton, new GUILayoutOption[0]))
                 {
                     this.m_LookDevView.envLibrary.RemoveHDRI(infos.cubemap);
                 }
             }
             GUILayout.EndHorizontal();
             Rect lastRect = GUILayoutUtility.GetLastRect();
             if ((Event.current.type == EventType.MouseDown) && lastRect.Contains(Event.current.mousePosition))
             {
                 Event.current.Use();
             }
             Rect rect = GUILayoutUtility.GetRect((float)250f, (float)125f);
             rect.width = 253f;
             float   num5      = 24f;
             float   num6      = num5 * 0.5f;
             float   latitude  = shadowInfo.latitude;
             float   longitude = shadowInfo.longitude;
             Vector2 vector2   = ((Vector2)(this.LatLongToPosition(latitude, longitude + infos.angleOffset) * 0.5f)) + new Vector2(0.5f, 0.5f);
             Rect    rect3     = rect;
             rect3.x      = (rect3.x + (vector2.x * rect.width)) - num6;
             rect3.y      = (rect3.y + ((1f - vector2.y) * rect.height)) - num6;
             rect3.width  = num5;
             rect3.height = num5;
             Rect rect4 = rect;
             rect4.x      = (rect4.x + (vector2.x * rect.width)) - (num6 * 0.5f);
             rect4.y      = (rect4.y + ((1f - vector2.y) * rect.height)) - (num6 * 0.5f);
             rect4.width  = num5 * 0.5f;
             rect4.height = num5 * 0.5f;
             this.GetFrameAndShadowTextureRect(rect, out rect5, out rect6);
             if (this.m_LookDevView.config.enableShadowCubemap)
             {
                 EditorGUIUtility.AddCursorRect(rect4, MouseCursor.Pan);
             }
             if ((Event.current.type == EventType.MouseDown) && rect.Contains(Event.current.mousePosition))
             {
                 if ((!Event.current.control && (Event.current.button == 0)) && (this.m_SelectedCubeMapOffsetIndex == -1))
                 {
                     if (this.m_LookDevView.config.enableShadowCubemap && rect4.Contains(Event.current.mousePosition))
                     {
                         this.m_SelectedLightIconIndex = i;
                         this.m_SelectedShadowInfo     = shadowInfo;
                         Undo.RecordObject(this.m_LookDevView.envLibrary, "Light Icon selection");
                         this.m_SelectedShadowInfo.latitude  += 0.0001f;
                         this.m_SelectedShadowInfo.longitude += 0.0001f;
                     }
                     if (this.m_SelectedShadowInfo == null)
                     {
                         Rect rect10 = rect5;
                         rect10.x     += 100f;
                         rect10.y     += 4f;
                         rect10.width  = 11f;
                         rect10.height = 11f;
                         if (this.m_LookDevView.config.enableShadowCubemap && rect10.Contains(Event.current.mousePosition))
                         {
                             Undo.RecordObject(this.m_LookDevView.envLibrary, "Update shadow cubemap");
                             hdriList[i].SetCubemapShadowInfo(hdriList[i]);
                             this.m_LookDevView.envLibrary.dirty = true;
                         }
                         else
                         {
                             if (this.m_LookDevView.config.enableShadowCubemap && rect6.Contains(Event.current.mousePosition))
                             {
                                 this.m_SelectedShadowCubemapOwnerInfo = hdriList[i];
                                 this.m_SelectedCubemapInfo            = this.m_SelectedShadowCubemapOwnerInfo.cubemapShadowInfo;
                             }
                             else
                             {
                                 this.m_SelectedCubemapInfo = hdriList[i];
                             }
                             this.m_SelectedPositionOffset     = Event.current.mousePosition - new Vector2(rect.x, rect.y);
                             this.m_RenderOverlayThumbnailOnce = true;
                         }
                     }
                 }
                 else if ((Event.current.control && (Event.current.button == 0)) && ((this.m_SelectedCubemapInfo == null) && (this.m_SelectedShadowInfo == null)))
                 {
                     this.m_SelectedCubeMapOffsetIndex = i;
                     this.m_SelectedCubeMapOffsetValue = infos.angleOffset - this.ComputeAngleOffsetFromMouseCoord(Event.current.mousePosition);
                 }
                 GUIUtility.hotControl = this.m_LookDevView.hotControl;
                 Event.current.Use();
             }
             if ((Event.current.GetTypeForControl(this.m_LookDevView.hotControl) == EventType.MouseDrag) && ((this.m_SelectedShadowInfo == shadowInfo) && (this.m_SelectedLightIconIndex == i)))
             {
                 Vector2 mousePosition = Event.current.mousePosition;
                 mousePosition.x = (((mousePosition.x - rect.x) / rect.width) * 2f) - 1f;
                 mousePosition.y = ((1f - ((mousePosition.y - rect.y) / rect.height)) * 2f) - 1f;
                 Vector2 vector4 = PositionToLatLong(mousePosition);
                 this.m_SelectedShadowInfo.latitude  = vector4.x;
                 this.m_SelectedShadowInfo.longitude = vector4.y - infos.angleOffset;
                 this.m_LookDevView.envLibrary.dirty = true;
             }
             if (Event.current.type == EventType.Repaint)
             {
                 this.DrawLatLongThumbnail(infos, infos.angleOffset, 1f, 1f, rect);
                 if (this.m_LookDevView.config.enableShadowCubemap)
                 {
                     if ((infos.cubemapShadowInfo != infos) || ((this.m_HoveringCubeMapIndex == i) && (this.m_SelectedCubemapInfo != infos)))
                     {
                         CubemapInfo cubemapShadowInfo = infos.cubemapShadowInfo;
                         if ((this.m_HoveringCubeMapIndex == i) && (this.m_SelectedCubemapInfo != infos))
                         {
                             cubemapShadowInfo = this.m_SelectedCubemapInfo;
                         }
                         float alpha = 1f;
                         if (this.m_SelectedShadowInfo == shadowInfo)
                         {
                             alpha = 0.1f;
                         }
                         else if (((this.m_HoveringCubeMapIndex == i) && (this.m_SelectedCubemapInfo != infos)) && (infos.cubemapShadowInfo != this.m_SelectedCubemapInfo))
                         {
                             alpha = 0.5f;
                         }
                         this.DrawLatLongThumbnail(cubemapShadowInfo, infos.angleOffset, 0.3f, alpha, rect6);
                         GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear;
                         GUI.DrawTexture(rect5, styles.sLatlongFrameTexture);
                         GL.sRGBWrite = false;
                     }
                     GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear;
                     GUI.DrawTexture(rect3, styles.sLightTexture);
                     GL.sRGBWrite = false;
                 }
                 if (flag2)
                 {
                     this.DrawSelectionFeedback(rect, black, firstViewGizmoColor);
                 }
             }
             GUILayout.EndVertical();
         }
         GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(250f) };
         GUILayout.BeginVertical(options);
         if (((this.m_SelectedCubemap != null) || this.m_DragBeingPerformed) && this.GetInsertionRect(hdriList.Count).Contains(Event.current.mousePosition))
         {
             GUILayout.Label(GUIContent.none, styles.sSeparatorStyle, new GUILayoutOption[0]);
             GUILayoutUtility.GetRect((float)250f, (float)16f);
             GUILayout.Label(GUIContent.none, styles.sSeparatorStyle, new GUILayoutOption[0]);
         }
         GUILayout.EndVertical();
         if (flag)
         {
             EditorGUILayout.EndScrollView();
         }
         this.HandleMouseInput();
         this.RenderOverlayThumbnailIfNeeded();
         if ((Event.current.type == EventType.Repaint) && (this.m_SelectedCubemap != null))
         {
             this.m_LookDevView.Repaint();
         }
     }
 }
示例#16
0
        public override void OnInspectorGUI()
        {
            bool GUIEnabledValue = GUI.enabled;

            if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline)
            {
                GUI.enabled = false;
            }

            if (m_Edited)
            {
                UpdateOrder(m_Edited);
                m_Edited = null;
            }

            EditorGUILayout.BeginVertical(EditorStyles.inspectorFullWidthMargins);
            {
                GUILayout.Label(Content.helpText, EditorStyles.helpBox);

                EditorGUILayout.Space();

                // Vertical that contains box and the toolbar below it
                Rect listRect = EditorGUILayout.BeginVertical();
                {
                    int        dropFieldId = EditorGUIUtility.GetControlID(s_DropFieldHash, FocusType.Passive, listRect);
                    MonoScript dropped     = EditorGUI.DoDropField(listRect, dropFieldId, typeof(MonoScript), MonoScriptValidatorCallback, false, Styles.dropField) as MonoScript;
                    if (dropped)
                    {
                        AddScriptToCustomOrder(dropped);
                    }

                    // Vertical that is used as a border around the scrollview
                    EditorGUILayout.BeginVertical(Styles.boxBackground);
                    {
                        // The scrollview itself
                        m_Scroll = EditorGUILayout.BeginVerticalScrollView(m_Scroll);
                        {
                            // List
                            Rect r       = GUILayoutUtility.GetRect(10, kListElementHeight * m_CustomTimeScripts.Count, GUILayout.ExpandWidth(true));
                            int  changed = DragReorderGUI.DragReorder(r, kListElementHeight, m_CustomTimeScripts, DrawElement);
                            if (changed >= 0)
                            {
                                // Give dragged item value in between neighbors
                                SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0);
                                // Update neighbors if needed
                                UpdateOrder(m_CustomTimeScripts[changed]);
                                // Neighbors may have been moved so there's more space around dragged item,
                                // so set order again to get possible rounding benefits
                                SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0);
                            }
                        } EditorGUILayout.EndScrollView();
                    } EditorGUILayout.EndVertical();

                    // The toolbar below the box
                    GUILayout.BeginHorizontal(Styles.toolbar);
                    {
                        GUILayout.FlexibleSpace();
                        Rect       r2;
                        GUIContent content = Content.iconToolbarPlus;
                        r2 = GUILayoutUtility.GetRect(content, Styles.toolbarDropDown);
                        if (EditorGUI.DropdownButton(r2, content, FocusType.Passive, Styles.toolbarDropDown))
                        {
                            ShowScriptPopup(r2);
                        }
                    } GUILayout.EndHorizontal();
                } GUILayout.EndVertical();

                ApplyRevertGUI();
            } GUILayout.EndVertical();

            GUI.enabled = GUIEnabledValue;
            if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline)
            {
                EditorGUILayout.HelpBox("Version control is disconnected", MessageType.Warning);
            }

            GUILayout.FlexibleSpace();
        }