BeginVerticalScrollView() static private method

static private BeginVerticalScrollView ( Vector2 scrollPosition ) : Vector2
scrollPosition Vector2
return Vector2
Ejemplo n.º 1
0
 public override void OnInspectorGUI()
 {
     EditorGUI.BeginDisabledGroup(false);
     GUILayout.Label("Select platforms for plugin", EditorStyles.boldLabel, new GUILayoutOption[0]);
     EditorGUILayout.BeginVertical(GUI.skin.box, new GUILayoutOption[0]);
     this.ShowGeneralOptions();
     EditorGUILayout.EndVertical();
     GUILayout.Space(10f);
     if (this.IsEditingPlatformSettingsSupported())
     {
         this.ShowPlatformSettings();
     }
     EditorGUI.EndDisabledGroup();
     base.ApplyRevertGUI();
     if (base.targets.Length <= 1)
     {
         GUILayout.Label("Information", EditorStyles.boldLabel, new GUILayoutOption[0]);
         this.m_InformationScrollPosition = EditorGUILayout.BeginVerticalScrollView(this.m_InformationScrollPosition, new GUILayoutOption[0]);
         foreach (KeyValuePair <string, string> pair in this.m_PluginInformation)
         {
             GUILayout.BeginHorizontal(new GUILayoutOption[0]);
             GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(50f) };
             GUILayout.Label(pair.Key, options);
             GUILayout.TextField(pair.Value, new GUILayoutOption[0]);
             GUILayout.EndHorizontal();
         }
         EditorGUILayout.EndScrollView();
         GUILayout.FlexibleSpace();
         if (this.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);
         }
     }
 }
        public override void OnInspectorGUI()
        {
            using (new EditorGUI.DisabledScope(false))
            {
                GUILayout.Label("Select platforms for plugin", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                ShowGeneralOptions();
                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

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

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

            GUILayout.Label("Information", 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);
            }
            if (EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy && importer.dllType == DllType.ManagedNET40 && m_CompatibleWithEditor == Compatibility.Compatible)
            {
                EditorGUILayout.HelpBox("Plugin targets .NET 4.x and is marked as compatible with Editor, Editor can only use assemblies targeting .NET 3.5 or lower, please unselect Editor as compatible platform.", MessageType.Error);
            }
            if (m_ReferencesUnityEngineModule != null)
            {
                EditorGUILayout.HelpBox($"This plugin references at least one UnityEngine module assemblies directly ({m_ReferencesUnityEngineModule}.dll). To assure forward compatibility, only reference UnityEngine.dll, which contains type forwarders for all the module dlls.", MessageType.Warning);
            }
        }
        public override void OnInspectorGUI()
        {
            if (ScriptExecutionOrderInspector.m_Styles == null)
            {
                ScriptExecutionOrderInspector.m_Styles = new ScriptExecutionOrderInspector.Styles();
            }
            if (this.m_Edited)
            {
                this.UpdateOrder(this.m_Edited);
                this.m_Edited = null;
            }
            EditorGUILayout.BeginVertical(EditorStyles.inspectorFullWidthMargins, new GUILayoutOption[0]);
            GUILayout.Label(ScriptExecutionOrderInspector.m_Styles.helpText, EditorStyles.helpBox, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            Rect       position   = EditorGUILayout.BeginVertical(new GUILayoutOption[0]);
            int        controlID  = GUIUtility.GetControlID(ScriptExecutionOrderInspector.s_DropFieldHash, FocusType.Passive, position);
            MonoScript monoScript = EditorGUI.DoDropField(position, controlID, typeof(MonoScript), new EditorGUI.ObjectFieldValidator(ScriptExecutionOrderInspector.MonoScriptValidatorCallback), false, ScriptExecutionOrderInspector.m_Styles.dropField) as MonoScript;

            if (monoScript)
            {
                this.AddScriptToCustomOrder(monoScript);
            }
            EditorGUILayout.BeginVertical(ScriptExecutionOrderInspector.m_Styles.boxBackground, new GUILayoutOption[0]);
            this.m_Scroll = EditorGUILayout.BeginVerticalScrollView(this.m_Scroll, new GUILayoutOption[0]);
            Rect rect = GUILayoutUtility.GetRect(10f, (float)(21 * this.m_CustomTimeScripts.Count), new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true)
            });
            int num = ScriptExecutionOrderInspector.DragReorderGUI.DragReorder(rect, 21, this.m_CustomTimeScripts, new ScriptExecutionOrderInspector.DragReorderGUI.DrawElementDelegate(this.DrawElement));

            if (num >= 0)
            {
                this.SetExecutionOrderAtIndexAccordingToNeighbors(num, 0);
                this.UpdateOrder(this.m_CustomTimeScripts[num]);
                this.SetExecutionOrderAtIndexAccordingToNeighbors(num, 0);
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
            GUILayout.BeginHorizontal(ScriptExecutionOrderInspector.m_Styles.toolbar, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUIContent iconToolbarPlus = ScriptExecutionOrderInspector.m_Styles.iconToolbarPlus;
            Rect       rect2           = GUILayoutUtility.GetRect(iconToolbarPlus, ScriptExecutionOrderInspector.m_Styles.toolbarDropDown);

            if (EditorGUI.ButtonMouseDown(rect2, iconToolbarPlus, FocusType.Native, ScriptExecutionOrderInspector.m_Styles.toolbarDropDown))
            {
                this.ShowScriptPopup(rect2);
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            this.ApplyRevertGUI();
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
        }
Ejemplo n.º 4
0
 public override void OnInspectorGUI()
 {
     using (new EditorGUI.DisabledScope(false))
     {
         GUILayout.Label("Select platforms for plugin", EditorStyles.boldLabel, new GUILayoutOption[0]);
         EditorGUILayout.BeginVertical(GUI.skin.box, new GUILayoutOption[0]);
         this.ShowGeneralOptions();
         EditorGUILayout.EndVertical();
         GUILayout.Space(10f);
         if (this.IsEditingPlatformSettingsSupported())
         {
             this.ShowPlatformSettings();
         }
     }
     base.ApplyRevertGUI();
     if (base.targets.Length <= 1)
     {
         GUILayout.Label("Information", EditorStyles.boldLabel, new GUILayoutOption[0]);
         this.m_InformationScrollPosition = EditorGUILayout.BeginVerticalScrollView(this.m_InformationScrollPosition, new GUILayoutOption[0]);
         foreach (KeyValuePair <string, string> current in this.m_PluginInformation)
         {
             GUILayout.BeginHorizontal(new GUILayoutOption[0]);
             GUILayout.Label(current.Key, new GUILayoutOption[]
             {
                 GUILayout.Width(85f)
             });
             EditorGUILayout.SelectableLabel(current.Value, new GUILayoutOption[]
             {
                 GUILayout.Height(16f)
             });
             GUILayout.EndHorizontal();
         }
         EditorGUILayout.EndScrollView();
         GUILayout.FlexibleSpace();
         if (this.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);
         }
         if (EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy && this.importer.dllType == DllType.ManagedNET40 && this.m_CompatibleWithEditor == PluginImporterInspector.Compatibility.Compatible)
         {
             EditorGUILayout.HelpBox("Plugin targets .NET 4.x and is marked as compatible with Editor, Editor can only use assemblies targeting .NET 3.5 or lower, please unselect Editor as compatible platform.", MessageType.Error);
         }
         if (this.m_ReferencesUnityEngineModule != null)
         {
             EditorGUILayout.HelpBox(string.Format("This plugin references at least one UnityEngine module assemblies directly ({0}.dll). To assure forward compatibility, only reference UnityEngine.dll, which contains type forwarders for all the module dlls.", this.m_ReferencesUnityEngineModule), MessageType.Warning);
         }
     }
 }
Ejemplo n.º 5
0
 public override void OnInspectorGUI()
 {
     EditorGUI.BeginDisabledGroup(false);
     GUILayout.Label("Select platforms for plugin", EditorStyles.boldLabel, new GUILayoutOption[0]);
     EditorGUILayout.BeginVertical(GUI.skin.box, new GUILayoutOption[0]);
     this.ShowGeneralOptions();
     EditorGUILayout.EndVertical();
     GUILayout.Space(10f);
     if (this.IsEditingPlatformSettingsSupported())
     {
         this.ShowPlatformSettings();
     }
     EditorGUI.EndDisabledGroup();
     this.ApplyRevertGUI();
     if (this.targets.Length > 1)
     {
         return;
     }
     GUILayout.Label("Information", EditorStyles.boldLabel, new GUILayoutOption[0]);
     this.m_InformationScrollPosition = EditorGUILayout.BeginVerticalScrollView(this.m_InformationScrollPosition);
     using (Dictionary <string, string> .Enumerator enumerator = this.m_PluginInformation.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             KeyValuePair <string, string> current = enumerator.Current;
             GUILayout.BeginHorizontal();
             GUILayout.Label(current.Key, new GUILayoutOption[1]
             {
                 GUILayout.Width(50f)
             });
             GUILayout.TextField(current.Value);
             GUILayout.EndHorizontal();
         }
     }
     EditorGUILayout.EndScrollView();
     GUILayout.FlexibleSpace();
     if (!this.importer.isNativePlugin)
     {
         return;
     }
     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);
 }
Ejemplo n.º 6
0
 public override void OnInspectorGUI()
 {
     using (new EditorGUI.DisabledScope(false))
     {
         GUILayout.Label("Select platforms for plugin", EditorStyles.boldLabel, new GUILayoutOption[0]);
         EditorGUILayout.BeginVertical(GUI.skin.box, new GUILayoutOption[0]);
         this.ShowGeneralOptions();
         EditorGUILayout.EndVertical();
         GUILayout.Space(10f);
         if (this.IsEditingPlatformSettingsSupported())
         {
             this.ShowPlatformSettings();
         }
     }
     base.ApplyRevertGUI();
     if (base.targets.Length <= 1)
     {
         GUILayout.Label("Information", EditorStyles.boldLabel, new GUILayoutOption[0]);
         this.m_InformationScrollPosition = EditorGUILayout.BeginVerticalScrollView(this.m_InformationScrollPosition, new GUILayoutOption[0]);
         foreach (KeyValuePair <string, string> current in this.m_PluginInformation)
         {
             GUILayout.BeginHorizontal(new GUILayoutOption[0]);
             GUILayout.Label(current.Key, new GUILayoutOption[]
             {
                 GUILayout.Width(85f)
             });
             GUILayout.TextField(current.Value, new GUILayoutOption[0]);
             GUILayout.EndHorizontal();
         }
         EditorGUILayout.EndScrollView();
         GUILayout.FlexibleSpace();
         if (this.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);
         }
         if (this.importer.dllType == DllType.ManagedNET40 && this.m_CompatibleWithEditor == PluginImporterInspector.Compatibility.Compatible)
         {
             EditorGUILayout.HelpBox("Plugin targets .NET 4.x and is marked as compatible with Editor, Editor can only use assemblies targeting .NET 3.5 or lower, please unselect Editor as compatible platform.", MessageType.Error);
         }
     }
 }
Ejemplo n.º 7
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("Select platforms for plugin", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                ShowGeneralOptions();
                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

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

                if (isManagedPlugin)
                {
                    GUILayout.Label(defineConstraints, EditorStyles.boldLabel);
                    m_DefineConstraints.DoLayoutList();
                }

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

            serializedObject.ApplyModifiedProperties();

            ApplyRevertGUI();

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

            GUILayout.Label("Information", 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);
            }
        }
Ejemplo n.º 8
0
        public override void OnInspectorGUI()
        {
            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();

            GUILayout.FlexibleSpace();
        }
Ejemplo n.º 9
0
        private void OnGUI()
        {
            EditorGUIUtility.labelWidth = (base.position.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           = "";
            float  alignmentOffset = 0f;

            switch (this.m_Terrain.materialType)
            {
            case Terrain.MaterialType.BuiltInStandard:
                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;
            }
            TextureFieldGUI(label, ref this.m_Texture, alignmentOffset);
            TextureFieldGUI("\nNormal", ref this.m_NormalMap, -4f);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            flag &= this.ValidateMainTexture(this.m_Texture);
            if (flag)
            {
                if (IsUsingMetallic(this.m_Terrain.materialType, this.m_Terrain.materialTemplate))
                {
                    EditorGUILayout.Space();
                    float labelWidth = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 75f;
                    this.m_Metallic             = EditorGUILayout.Slider("Metallic", this.m_Metallic, 0f, 1f, new GUILayoutOption[0]);
                    EditorGUIUtility.labelWidth = labelWidth;
                }
                else if (IsUsingSpecular(this.m_Terrain.materialType, this.m_Terrain.materialTemplate))
                {
                    this.m_Specular = EditorGUILayout.ColorField("Specular", this.m_Specular, new GUILayoutOption[0]);
                }
                if (IsUsingSmoothness(this.m_Terrain.materialType, this.m_Terrain.materialTemplate) && !TextureUtil.HasAlphaTextureFormat(this.m_Texture.format))
                {
                    EditorGUILayout.Space();
                    float num3 = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 75f;
                    this.m_Smoothness           = EditorGUILayout.Slider("Smoothness", this.m_Smoothness, 0f, 1f, new GUILayoutOption[0]);
                    EditorGUIUtility.labelWidth = num3;
                }
            }
            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;
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinWidth(100f) };
            if (GUILayout.Button(this.m_ButtonTitle, options))
            {
                this.ApplyTerrainSplat();
                base.Close();
                GUIUtility.ExitGUI();
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();
            if ((flag2 && flag) && (this.m_Index != -1))
            {
                this.ApplyTerrainSplat();
            }
        }
Ejemplo n.º 10
0
        private void OnGUI()
        {
            EditorGUIUtility.labelWidth = 150f;
            GUILayout.Label(this.m_HelpString, EditorStyles.wordWrappedLabel, new GUILayoutOption[]
            {
                GUILayout.ExpandHeight(true)
            });
            this.m_ScrollPosition = EditorGUILayout.BeginVerticalScrollView(this.m_ScrollPosition, false, GUI.skin.verticalScrollbar, "OL Box", new GUILayoutOption[0]);
            GUIUtility.GetControlID(645789, FocusType.Passive);
            bool flag = this.DrawWizardGUI();

            EditorGUILayout.EndScrollView();
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            if (this.m_ErrorString != string.Empty)
            {
                GUILayout.Label(this.m_ErrorString, ScriptableWizard.Styles.errorText, new GUILayoutOption[]
                {
                    GUILayout.MinHeight(32f)
                });
            }
            else
            {
                GUILayout.Label(string.Empty, new GUILayoutOption[]
                {
                    GUILayout.MinHeight(32f)
                });
            }
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUI.enabled = this.m_IsValid;
            if (this.m_OtherButton != string.Empty && GUILayout.Button(this.m_OtherButton, new GUILayoutOption[]
            {
                GUILayout.MinWidth(100f)
            }))
            {
                MethodInfo method = base.GetType().GetMethod("OnWizardOtherButton", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
                if (method != null)
                {
                    method.Invoke(this, null);
                    GUIUtility.ExitGUI();
                }
                else
                {
                    Debug.LogError("OnWizardOtherButton has not been implemented in script");
                }
            }
            if (this.m_CreateButton != string.Empty && GUILayout.Button(this.m_CreateButton, new GUILayoutOption[]
            {
                GUILayout.MinWidth(100f)
            }))
            {
                MethodInfo method2 = base.GetType().GetMethod("OnWizardCreate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
                if (method2 != null)
                {
                    method2.Invoke(this, null);
                }
                else
                {
                    Debug.LogError("OnWizardCreate has not been implemented in script");
                }
                base.Close();
                GUIUtility.ExitGUI();
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            if (flag)
            {
                this.InvokeWizardUpdate();
            }
        }
Ejemplo n.º 11
0
        private void OnGUI()
        {
            const float controlSize = 64;

            EditorGUIUtility.labelWidth = position.width - controlSize - 20;

            bool isValid = true;

            m_ScrollPosition = EditorGUILayout.BeginVerticalScrollView(m_ScrollPosition, false, GUI.skin.verticalScrollbar, GUI.skin.scrollView);

            isValid &= ValidateTerrain();

            EditorGUI.BeginChangeCheck();

            // texture & normal map
            GUILayout.BeginHorizontal();

            string textureLabel    = "";
            float  alignmentOffset = 0.0f;

            switch (m_Terrain.materialType)
            {
            case Terrain.MaterialType.BuiltInLegacyDiffuse:
                textureLabel    = "\n Diffuse (RGB)";
                alignmentOffset = 15.0f;
                break;

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

            case Terrain.MaterialType.BuiltInStandard:
                textureLabel    = " Albedo (RGB)\nSmoothness (A)";
                alignmentOffset = 15.0f;
                break;

            case Terrain.MaterialType.Custom:
                textureLabel    = " \n  Splat";
                alignmentOffset = 0.0f;
                break;
            }

            TextureFieldGUI(textureLabel, ref m_Texture, alignmentOffset);

            Texture2D oldNormalMap = m_NormalMap;

            TextureFieldGUI("\nNormal", ref m_NormalMap, -4.0f);

            if (m_NormalMap != oldNormalMap)
            {
                CheckIfNormalMapHasCorrectTextureType();
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            isValid &= ValidateTextures();

            // PBR text & settings
            if (isValid)
            {
                if (IsUsingMetallic(m_Terrain.materialType, m_Terrain.materialTemplate))
                {
                    EditorGUILayout.Space();
                    float oldLabelWidth = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 75.0f;
                    m_Metallic = EditorGUILayout.Slider("Metallic", m_Metallic, 0.0f, 1.0f);
                    EditorGUIUtility.labelWidth = oldLabelWidth;
                }
                else if (IsUsingSpecular(m_Terrain.materialType, m_Terrain.materialTemplate))
                {
                    m_Specular = EditorGUILayout.ColorField("Specular", m_Specular);
                }

                if (IsUsingSmoothness(m_Terrain.materialType, m_Terrain.materialTemplate) && !TextureUtil.HasAlphaTextureFormat(m_Texture.format))
                {
                    EditorGUILayout.Space();
                    float oldLabelWidth = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 75.0f;
                    m_Smoothness = EditorGUILayout.Slider("Smoothness", m_Smoothness, 0.0f, 1.0f);
                    EditorGUIUtility.labelWidth = oldLabelWidth;
                }
            }

            // tiling & offset
            SplatSizeGUI(ref m_TileSize, ref m_TileOffset);

            bool modified = EditorGUI.EndChangeCheck();

            EditorGUILayout.EndScrollView();

            GUILayout.FlexibleSpace();

            // button
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUI.enabled = isValid;

            if (GUILayout.Button(m_ButtonTitle, GUILayout.MinWidth(100)))
            {
                ApplyTerrainSplat();
                Close();
                GUIUtility.ExitGUI();
            }
            GUI.enabled = true;

            GUILayout.EndHorizontal();

            if (modified && isValid && m_Index != -1)
            {
                ApplyTerrainSplat();
            }
        }
        //@TODO: Force repaint if scripts recompile
        private void OnGUI()
        {
            EditorGUIUtility.labelWidth = 150;
            GUILayout.Label(m_HelpString, EditorStyles.wordWrappedLabel, GUILayout.ExpandHeight(true));

            // Render contents using Generic Inspector GUI
            m_ScrollPosition = EditorGUILayout.BeginVerticalScrollView(m_ScrollPosition, false, GUI.skin.verticalScrollbar, "OL Box");
            GUIUtility.GetControlID(645789, FocusType.Passive);
            bool modified = DrawWizardGUI();

            EditorGUILayout.EndScrollView();

            // Create and Other Buttons
            GUILayout.BeginVertical();
            if (m_ErrorString != string.Empty)
            {
                GUILayout.Label(m_ErrorString, Styles.errorText, GUILayout.MinHeight(32));
            }
            else
            {
                GUILayout.Label(string.Empty, GUILayout.MinHeight(32));
            }
            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUI.enabled = m_IsValid;

            const BindingFlags kInstanceInvokeFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy;

            if (m_OtherButton != "" && GUILayout.Button(m_OtherButton, GUILayout.MinWidth(100)))
            {
                MethodInfo method = GetType().GetMethod("OnWizardOtherButton", kInstanceInvokeFlags);
                if (method != null)
                {
                    method.Invoke(this, null);
                    GUIUtility.ExitGUI();
                }
                else
                {
                    Debug.LogError("OnWizardOtherButton has not been implemented in script");
                }
            }

            if (m_CreateButton != "" && GUILayout.Button(m_CreateButton, GUILayout.MinWidth(100)))
            {
                MethodInfo method = GetType().GetMethod("OnWizardCreate", kInstanceInvokeFlags);
                if (method != null)
                {
                    method.Invoke(this, null);
                }
                else
                {
                    Debug.LogError("OnWizardCreate has not been implemented in script");
                }
                Close();
                GUIUtility.ExitGUI();
            }
            GUI.enabled = true;

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            if (modified)
            {
                InvokeWizardUpdate();
            }

            GUILayout.Space(8);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 14
0
 public override void OnInspectorGUI()
 {
     EditorGUI.BeginDisabledGroup(false);
     BuildPlayerWindow.BuildPlatform[] buildPlayerValidPlatforms = this.GetBuildPlayerValidPlatforms();
     GUILayout.Label("Select platforms for plugin", EditorStyles.boldLabel, new GUILayoutOption[0]);
     EditorGUILayout.BeginVertical(GUI.skin.box, new GUILayoutOption[0]);
     this.ShowGeneralOptions();
     EditorGUILayout.EndVertical();
     EditorGUI.BeginChangeCheck();
     if (EditorGUI.EndChangeCheck())
     {
         this.hasModified = true;
     }
     GUILayout.Space(10f);
     if (buildPlayerValidPlatforms.Length > 0)
     {
         GUILayout.Label("Platform settings", EditorStyles.boldLabel, new GUILayoutOption[0]);
         int num = EditorGUILayout.BeginPlatformGrouping(buildPlayerValidPlatforms, null);
         if (buildPlayerValidPlatforms[num].name == BuildPipeline.GetEditorTargetName())
         {
             this.ShowEditorSettings();
         }
         else
         {
             BuildTargetGroup targetGroup = buildPlayerValidPlatforms[num].targetGroup;
             if (targetGroup == BuildTargetGroup.Standalone)
             {
                 this.desktopExtension.OnPlatformSettingsGUI(this);
             }
             else
             {
                 IPluginImporterExtension pluginImporterExtension = ModuleManager.GetPluginImporterExtension(targetGroup);
                 if (pluginImporterExtension != null)
                 {
                     pluginImporterExtension.OnPlatformSettingsGUI(this);
                 }
             }
         }
         EditorGUILayout.EndPlatformGrouping();
     }
     EditorGUI.EndDisabledGroup();
     base.ApplyRevertGUI();
     GUILayout.Label("Information", EditorStyles.boldLabel, new GUILayoutOption[0]);
     this.informationScrollPosition = EditorGUILayout.BeginVerticalScrollView(this.informationScrollPosition, new GUILayoutOption[0]);
     foreach (KeyValuePair <string, string> current in this.pluginInformation)
     {
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         GUILayout.Label(current.Key, new GUILayoutOption[]
         {
             GUILayout.Width(50f)
         });
         GUILayout.TextField(current.Value, new GUILayoutOption[0]);
         GUILayout.EndHorizontal();
     }
     EditorGUILayout.EndScrollView();
     GUILayout.FlexibleSpace();
     if (this.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);
     }
 }