예제 #1
0
        public override void OnInspectorGUI()
        {
            Initialize();

            InitializeStyle();

            var instance = target as LocalizeSpriteAsset;

            var removeInfos = new List <LocalizeSpriteAsset.FolderInfo>();

            var update = false;

            GUILayout.Space(4f);

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(toolbarPlusIcon, GUILayout.Width(50f), GUILayout.Height(16f)))
                {
                    var info = new LocalizeSpriteAsset.FolderInfo();

                    folderInfos.Add(info);

                    update = true;
                }

                GUILayout.Space(8f);
            }

            var swapTargets = new List <Tuple <int, int> >();

            using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPosition, GUILayout.ExpandWidth(true)))
            {
                for (var i = 0; i < folderInfos.Count; i++)
                {
                    var info = folderInfos[i];

                    using (new ContentsScope())
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            EditorGUI.BeginChangeCheck();

                            var index = EditorGUILayout.DelayedIntField("Index", i, inputFieldStyle, GUILayout.Height(16f), GUILayout.ExpandWidth(true));

                            if (EditorGUI.EndChangeCheck())
                            {
                                if (0 <= index && index < folderInfos.Count)
                                {
                                    swapTargets.Add(Tuple.Create(i, index));
                                }
                            }

                            GUILayout.FlexibleSpace();

                            if (GUILayout.Button(toolbarMinusIcon, EditorStyles.miniButton, GUILayout.Width(35f)))
                            {
                                removeInfos.Add(info);
                            }
                        }

                        GUILayout.Space(2f);

                        UnityEngine.Object folder = null;

                        if (!string.IsNullOrEmpty(info.guid))
                        {
                            var assetPath = AssetDatabase.GUIDToAssetPath(info.guid);

                            folder = AssetDatabase.LoadMainAssetAtPath(assetPath);
                        }

                        var layoutOption = new GUILayoutOption[]
                        {
                            GUILayout.Height(16f), GUILayout.ExpandWidth(true),
                        };

                        EditorGUI.BeginChangeCheck();

                        folder = EditorGUILayout.ObjectField("Atlas Folder", folder, typeof(UnityEngine.Object), false, layoutOption);

                        GUILayout.Space(2f);

                        info.description = EditorGUILayout.DelayedTextField("Description", info.description, inputFieldStyle, layoutOption);

                        if (EditorGUI.EndChangeCheck())
                        {
                            // フォルダだけ登録可能.
                            if (UnityEditorUtility.IsFolder(folder) || folder == null)
                            {
                                info.guid = folder == null ? string.Empty : UnityEditorUtility.GetAssetGUID(folder);
                            }

                            update = true;
                        }
                    }

                    GUILayout.Space(4f);
                }

                scrollPosition = scrollView.scrollPosition;
            }

            if (swapTargets.Any())
            {
                foreach (var swapTarget in swapTargets)
                {
                    folderInfos = folderInfos.Swap(swapTarget.Item1, swapTarget.Item2).ToList();
                }

                update = true;
            }

            if (removeInfos.Any())
            {
                foreach (var info in removeInfos)
                {
                    folderInfos.Remove(info);
                }

                update = true;
            }

            if (update)
            {
                var infos = folderInfos
                            .Select(x =>
                {
                    var info         = x.DeepCopy();
                    info.description = info.description.Encrypt(cryptoKey);
                    return(info);
                })
                            .ToArray();

                Reflection.SetPrivateField(instance, "infos", infos);

                isChanged = true;
            }
        }
예제 #2
0
            protected override string DrawContent(int index, string content)
            {
                content = EditorGUILayout.DelayedTextField(content);

                return(content);
            }
예제 #3
0
 public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target)
 {
     return(EditorGUILayout.DelayedTextField(memberName, (string)value));
 }
예제 #4
0
        void OnGUI()
        {
            var unityConsoleManager = UnityConsoleManager.Instance;

            EditorGUILayout.Separator();

            var isEnable = unityConsoleManager.IsEnable();

            EditorGUI.BeginChangeCheck();

            isEnable = EditorGUILayout.Toggle("UnityConsole Enable", isEnable);

            if (EditorGUI.EndChangeCheck())
            {
                unityConsoleManager.SetEnable(isEnable);
            }

            GUILayout.Space(2f);

            using (new ContentsScope())
            {
                using (var scrollViewScope = new EditorGUILayout.ScrollViewScope(scrollPosition))
                {
                    var removeList = new List <ConsoleInfo>();

                    foreach (var consoleInfo in consoleInfos)
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            using (new DisableScope(consoleInfo.eventName == UnityConsole.InfoEvent.ConsoleEventName))
                            {
                                consoleInfo.eventName = EditorGUILayout.DelayedTextField(consoleInfo.eventName);
                            }

                            GUILayout.Space(5f);

                            using (new LabelWidthScope(0f))
                            {
                                consoleInfo.enable = EditorGUILayout.Toggle(consoleInfo.enable, GUILayout.Width(18f));
                            }

                            var disableDelete = false;

                            disableDelete |= consoleInfo.eventName == UnityConsole.InfoEvent.ConsoleEventName;
                            disableDelete |= IsDefinedInfo(consoleInfo.eventName);

                            using (new DisableScope(disableDelete))
                            {
                                if (GUILayout.Button("-", GUILayout.Height(18f)))
                                {
                                    removeList.Add(consoleInfo);
                                }
                            }
                        }
                    }

                    foreach (var item in removeList)
                    {
                        consoleInfos.Remove(item);
                    }

                    scrollPosition = scrollViewScope.scrollPosition;
                }
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                if (GUILayout.Button("+"))
                {
                    var newInfo = new ConsoleInfo()
                    {
                        eventName = string.Empty,
                        enable    = true,
                    };

                    consoleInfos.Add(newInfo);
                }

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Save"))
                {
                    unityConsoleManager.Save(consoleInfos);
                }
            }
        }
        private void HandleTextureSettingUI()
        {
            EditorGUILayout.LabelField(styles.textureSettingLabel, EditorStyles.boldLabel);

            HandleBoolToIntPropertyField(m_Readable, styles.readWrite);
            HandleBoolToIntPropertyField(m_GenerateMipMaps, styles.generateMipMapLabel);
            HandleBoolToIntPropertyField(m_UseSRGB, styles.sRGBLabel);
            EditorGUILayout.PropertyField(m_FilterMode);

            var showAniso = !m_FilterMode.hasMultipleDifferentValues && !m_GenerateMipMaps.hasMultipleDifferentValues &&
                            (FilterMode)m_FilterMode.intValue != FilterMode.Point && m_GenerateMipMaps.boolValue;

            if (showAniso)
            {
                EditorGUILayout.IntSlider(m_AnisoLevel, 0, 16);
            }

            GUILayout.Space(EditorGUI.kSpacing);

            // "Show Platform Settings For" dropdown
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel(s_Styles.platformSettingsDropDownLabel);

                EditorGUI.BeginChangeCheck();
                m_SelectedPlatformSettings = EditorGUILayout.Popup(m_SelectedPlatformSettings, m_PlatformSettingsOptions.ToArray(), GUILayout.MaxWidth(150.0f));
                if (EditorGUI.EndChangeCheck())
                {
                    // New settings option is selected...
                    if (m_SelectedPlatformSettings == m_PlatformSettingsOptions.Count - 1)
                    {
                        m_PlatformSettingsOptions.Insert(m_SelectedPlatformSettings - 1, s_Styles.defaultTextForSecondaryTextureName);
                        m_SelectedPlatformSettings--;
                        EditorGUI.FocusTextInControl(s_Styles.secondaryTextureNameTextControlName);
                    }

                    SyncPlatformSettings();
                }

                if (secondaryTextureSelected)
                {
                    // trash can button
                    if (GUILayout.Button(s_Styles.trashIcon, EditorStyles.iconButton, GUILayout.ExpandWidth(false)))
                    {
                        EditorGUI.EndEditingActiveTextField();

                        foreach (SpriteAtlas sa in targets)
                        {
                            sa.DeleteSecondaryPlatformSettings(m_PlatformSettingsOptions[m_SelectedPlatformSettings]);
                        }

                        m_PlatformSettingsOptions.RemoveAt(m_SelectedPlatformSettings);

                        m_SelectedPlatformSettings--;
                        if (m_SelectedPlatformSettings == 1)
                        {
                            m_SelectedPlatformSettings = 0;
                        }

                        SyncPlatformSettings();
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            // Texture platform settings UI.
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUI.indentLevel++;
                GUILayout.Space(EditorGUI.indent);
                EditorGUI.indentLevel--;

                if (m_SelectedPlatformSettings == 0)
                {
                    HandlePlatformSettingUI(null);
                }
                else
                {
                    EditorGUILayout.BeginVertical();
                    {
                        string oldSecondaryTextureName = m_PlatformSettingsOptions[m_SelectedPlatformSettings];
                        GUI.SetNextControlName(s_Styles.secondaryTextureNameTextControlName);

                        EditorGUI.BeginChangeCheck();
                        string textFieldText = EditorGUILayout.DelayedTextField(s_Styles.secondaryTextureNameLabel, oldSecondaryTextureName);
                        if (EditorGUI.EndChangeCheck() && oldSecondaryTextureName != textFieldText)
                        {
                            if (!m_PlatformSettingsOptions.Exists(x => x == textFieldText))
                            {
                                m_PlatformSettingsOptions[m_SelectedPlatformSettings] = textFieldText;
                                RenameSecondaryPlatformSettings(oldSecondaryTextureName, textFieldText);
                            }
                            else
                            {
                                Debug.LogWarning(s_Styles.nameUniquenessWarning);
                                EditorGUI.FocusTextInControl(s_Styles.secondaryTextureNameTextControlName);
                            }
                        }

                        string      secondaryTextureName = m_PlatformSettingsOptions[m_SelectedPlatformSettings];
                        SpriteAtlas sa = (SpriteAtlas)target;
                        EditorGUI.BeginChangeCheck();
                        bool value = EditorGUILayout.Toggle(s_Styles.sRGBLabel, sa.GetSecondaryColorSpace(secondaryTextureName));
                        if (EditorGUI.EndChangeCheck())
                        {
                            sa.SetSecondaryColorSpace(secondaryTextureName, value);
                        }

                        HandlePlatformSettingUI(textFieldText);
                    }
                    EditorGUILayout.EndVertical();
                }
            }
            EditorGUILayout.EndHorizontal();
        }
예제 #6
0
파일: VSCode.cs 프로젝트: Toxiiic/Care-me
        static void VSCodePreferencesItem()
        {
            if (EditorApplication.isCompiling)
            {
                EditorGUILayout.HelpBox("Please wait for Unity to finish compiling. \nIf the window doesn't refresh, simply click on the window or move it around to cause a repaint to happen.", MessageType.Warning);
                return;
            }
            EditorGUILayout.BeginVertical();

            var developmentInfo = "Support development of this plugin, follow @reapazor and @dotbunny on Twitter.";
            var versionInfo     = string.Format("{0:0.00}", Version) + VersionCode + ", GitHub version @ " + string.Format("{0:0.00}", GitHubVersion);

            EditorGUILayout.HelpBox(developmentInfo + " --- [ " + versionInfo + " ]", MessageType.None);

            EditorGUI.BeginChangeCheck();

// Need the VS Code executable
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("VS Code Path", GUILayout.Width(75));
#if UNITY_5_3_OR_NEWER
            CodePath = EditorGUILayout.DelayedTextField(CodePath, GUILayout.ExpandWidth(true));
#else
            CodePath = EditorGUILayout.TextField(CodePath, GUILayout.ExpandWidth(true));
#endif
            GUI.SetNextControlName("PathSetButton");
            if (GUILayout.Button("...", GUILayout.Height(14), GUILayout.Width(20)))
            {
                GUI.FocusControl("PathSetButton");
                string path = EditorUtility.OpenFilePanel("Visual Studio Code Executable", "", "");
                if (path.Length != 0 && File.Exists(path) || Directory.Exists(path))
                {
                    CodePath = path;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            Enabled = EditorGUILayout.Toggle(new GUIContent("Enable Integration", "Should the integration work its magic for you?"), Enabled);

            UseUnityDebugger = EditorGUILayout.Toggle(new GUIContent("Use Unity Debugger", "Should the integration integrate with Unity's VSCode Extension (must be installed)."), UseUnityDebugger);

            AutoOpenEnabled = EditorGUILayout.Toggle(new GUIContent("Enable Auto Open", "When opening a project in Unity, should it automatically open in VS Code?"), AutoOpenEnabled);

            EditorGUILayout.Space();
            RevertExternalScriptEditorOnExit = EditorGUILayout.Toggle(new GUIContent("Revert Script Editor On Unload", "Should the external script editor setting be reverted to its previous setting on project unload? This is useful if you do not use Code with all your projects."), RevertExternalScriptEditorOnExit);

            Debug = EditorGUILayout.Toggle(new GUIContent("Output Messages To Console", "Should informational messages be sent to Unity's Console?"), Debug);

            WriteLaunchFile = EditorGUILayout.Toggle(new GUIContent("Always Write Launch File", "Always write the launch.json settings when entering play mode?"), WriteLaunchFile);

            EditorGUILayout.Space();

            AutomaticUpdates = EditorGUILayout.Toggle(new GUIContent("Automatic Updates", "Should the plugin automatically update itself?"), AutomaticUpdates);

            UpdateTime = EditorGUILayout.IntSlider(new GUIContent("Update Timer (Days)", "After how many days should updates be checked for?"), UpdateTime, 1, 31);

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            if (EditorGUI.EndChangeCheck())
            {
                UpdateUnityPreferences(Enabled);

                // TODO: Force Unity To Reload Preferences
                // This seems to be a hick up / issue
                if (VSCode.Debug)
                {
                    if (Enabled)
                    {
                        UnityEngine.Debug.Log("[VSCode] Integration Enabled");
                    }
                    else
                    {
                        UnityEngine.Debug.Log("[VSCode] Integration Disabled");
                    }
                }
            }

            if (GUILayout.Button(new GUIContent("Force Update", "Check for updates to the plugin, right NOW!")))
            {
                CheckForUpdate();
                EditorGUILayout.EndVertical();
                return;
            }
            if (GUILayout.Button(new GUIContent("Write Workspace Settings", "Output a default set of workspace settings for VSCode to use, ignoring many different types of files.")))
            {
                WriteWorkspaceSettings();
                EditorGUILayout.EndVertical();
                return;
            }
            EditorGUILayout.Space();

            if (UseUnityDebugger)
            {
                EditorGUILayout.HelpBox("In order for the \"Use Unity Debuggger\" option to function above, you need to have installed the Unity Debugger Extension for Visual Studio Code.", MessageType.Warning);
                if (GUILayout.Button(new GUIContent("Install Unity Debugger", "Install the Unity Debugger Extension into Code")))
                {
                    InstallUnityDebugger();
                    EditorGUILayout.EndVertical();
                    return;
                }
            }
        }
예제 #7
0
	private bool DrawAdvancedSettings()
	{
	    bool bChanged = false;

	    GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
	    labelStyle.normal.textColor = HEU_EditorUI.GetUISafeTextColorYellow();
	    EditorGUILayout.LabelField("Warning: Changing these values from default might result in HDAs not loading properly!", labelStyle, GUILayout.MinHeight(30));
	    HEU_EditorUI.DrawSeparator();

	    EditorGUIUtility.labelWidth = 250;
	    {
		string oldValue = HEU_PluginSettings.HDAData_Name;
		string newValue = EditorGUILayout.DelayedTextField("HDA Data GameObject Name", oldValue);
		if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
		{
		    HEU_PluginSettings.HDAData_Name = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.EditorOnly_Tag;
		string newValue = EditorGUILayout.DelayedTextField("HDA Data GameObject Tag", oldValue);
		if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
		{
		    HEU_PluginSettings.EditorOnly_Tag = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.CollisionGroupName;
		string newValue = EditorGUILayout.DelayedTextField("Collision Group", oldValue);
		if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
		{
		    HEU_PluginSettings.CollisionGroupName = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.RenderedCollisionGroupName;
		string newValue = EditorGUILayout.DelayedTextField("Rendered Collision Group", oldValue);
		if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
		{
		    HEU_PluginSettings.RenderedCollisionGroupName = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.UnityMaterialAttribName;
		string newValue = EditorGUILayout.DelayedTextField("Unity Material Attribute", oldValue);
		if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
		{
		    HEU_PluginSettings.UnityMaterialAttribName = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.UnitySubMaterialAttribName;
		string newValue = EditorGUILayout.DelayedTextField("Unity Substance Material Attribute", oldValue);
		if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
		{
		    HEU_PluginSettings.UnitySubMaterialAttribName = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.UnityTagAttributeName;
		string newValue = EditorGUILayout.DelayedTextField("Unity Tag Attribute", oldValue);
		if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
		{
		    HEU_PluginSettings.UnityTagAttributeName = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.UnityScriptAttributeName;
		string newValue = EditorGUILayout.DelayedTextField("Unity Script Attribute", oldValue);
		if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
		{
		    HEU_PluginSettings.UnityScriptAttributeName = newValue;
		    bChanged = true;
		}
	    }

	    EditorGUIUtility.labelWidth = 0;

	    return bChanged;
	}
                private void RenderTable()
                {
                    _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, false, false);
                    {
                        float          defaultItemHeight = GetItemHeight();
                        SystemLanguage currentLanguage   = Localisation.GetCurrentLanguage();
                        float          secondLangWidth   = position.width - _editorPrefs._keyWidth - _editorPrefs._firstLanguageWidth;

                        //On layout, check what part of table is currently being viewed
                        if (Event.current.type == EventType.Layout || _keysDirty)
                        {
                            GetViewableRange(_scrollPosition.y, GetTableAreaHeight(), defaultItemHeight, out _viewStartIndex, out _viewEndIndex, out _contentStart, out _contentHeight);
                        }

                        EditorGUILayout.BeginVertical(GUILayout.Height(_contentHeight));
                        {
                            //Blank space until start of content
                            GUILayout.Label(GUIContent.none, GUILayout.Height(_contentStart));

                            //Then render viewable range
                            for (int i = _viewStartIndex; i < _viewEndIndex; i++)
                            {
                                bool selected = IsSelected(_keys[i]);

                                Color origBackgroundColor = GUI.backgroundColor;
                                GUI.backgroundColor = selected ? kSelectedTextLineBackgroundColor : i % 2 == 0 ? kTextLineBackgroundColorA : kTextLineBackgroundColorB;

                                //Work out item height
                                float itemHeight;
                                {
                                    if (selected)
                                    {
                                        //Work out highest text size
                                        string textA       = Localisation.GetRawString(_keys[i], Localisation.GetCurrentLanguage());
                                        float  textAHeight = _editTextStyle.CalcHeight(new GUIContent(textA), _editorPrefs._firstLanguageWidth);

                                        string textB       = Localisation.GetRawString(_keys[i], _editorPrefs._secondLanguage);
                                        float  textBHeight = _editTextStyle.CalcHeight(new GUIContent(textB), secondLangWidth);

                                        float textHeight = Mathf.Max(textAHeight, textBHeight);

                                        itemHeight = Mathf.Max(defaultItemHeight, textHeight);
                                    }
                                    else
                                    {
                                        itemHeight = defaultItemHeight;
                                    }
                                }

                                //Render item
                                EditorGUILayout.BeginHorizontal(_tableStyle, GUILayout.Height(itemHeight));
                                {
                                    GUI.backgroundColor = origBackgroundColor;

                                    //Render Key
                                    EditorGUILayout.BeginVertical();
                                    {
                                        if (_editingKeyName == _keys[i])
                                        {
                                            EditorGUI.BeginChangeCheck();
                                            string key = EditorGUILayout.DelayedTextField(_keys[i], _editKeyStyle, GUILayout.Width(_editorPrefs._keyWidth), GUILayout.Height(itemHeight));
                                            if (EditorGUI.EndChangeCheck())
                                            {
                                                _editingKeyName = null;
                                                Localisation.ChangeKey(_keys[i], key);
                                                UpdateKeys();
                                            }
                                        }
                                        else
                                        {
                                            if (GUILayout.Button(_keys[i], _keyStyle, GUILayout.Width(_editorPrefs._keyWidth), GUILayout.Height(itemHeight)))
                                            {
                                                OnClickItem(i, SystemLanguage.Unknown);
                                            }
                                        }
                                    }
                                    EditorGUILayout.EndVertical();

                                    //Render Text
                                    {
                                        GUI.backgroundColor = selected ? kSelectedTextBackgroundColor : i % 2 == 0 ? kTextBackgroundColorA : kTextBackgroundColorB;

                                        //Render First Language
                                        string text = Localisation.GetRawString(_keys[i], currentLanguage);

                                        if (GUILayout.Button(selected ? text : StringUtils.GetFirstLine(text), selected ? _editTextStyle : _textStyle, GUILayout.Width(_editorPrefs._firstLanguageWidth), GUILayout.Height(itemHeight)))
                                        {
                                            OnClickItem(i, currentLanguage);
                                        }

                                        //Render Second Language
                                        EditorGUILayout.BeginVertical(GUILayout.Width(secondLangWidth));
                                        {
                                            string stext = Localisation.GetRawString(_keys[i], _editorPrefs._secondLanguage);

                                            if (GUILayout.Button(selected ? stext : StringUtils.GetFirstLine(stext), selected ? _editTextStyle : _textStyle, GUILayout.Width(secondLangWidth), GUILayout.Height(itemHeight)))
                                            {
                                                OnClickItem(i, _editorPrefs._secondLanguage);
                                            }
                                        }
                                        EditorGUILayout.EndVertical();
                                    }
                                }
                                EditorGUILayout.EndHorizontal();

                                GUI.backgroundColor = origBackgroundColor;
                            }
                        }
                        EditorGUILayout.EndVertical();
                    }
                    EditorGUILayout.EndScrollView();
                }
예제 #9
0
	private bool DrawDetailsGeometry()
	{
	    bool bChanged = false;

	    EditorGUIUtility.labelWidth = 250;

	    {
		bool oldValue = HEU_PluginSettings.Curves_ShowInSceneView;
		bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Show Curves in Scene View");
		if (newValue != oldValue)
		{
		    HEU_PluginSettings.Curves_ShowInSceneView = newValue;
		    HEU_HoudiniAsset.SetCurvesVisibilityInScene(newValue);
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		int oldValue = HEU_PluginSettings.MaxVerticesPerPrimitive;
		int newValue = EditorGUILayout.DelayedIntField("Max Vertices Per Primitive", oldValue);
		if (newValue != oldValue)
		{
		    if (newValue == 3 || newValue == 4)
		    {
			HEU_PluginSettings.MaxVerticesPerPrimitive = newValue;
			bChanged = true;
		    }
		    else
		    {
			Debug.LogWarningFormat("Plugin only supports 3 (triangles) or 4 (quads) max vertices values.");
		    }
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		float oldValue = HEU_PluginSettings.NormalGenerationThresholdAngle;
		float newValue = EditorGUILayout.DelayedFloatField("Normal Generation Threshold Angle", oldValue);
		if (newValue != oldValue)
		{
		    HEU_PluginSettings.NormalGenerationThresholdAngle = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.DefaultTerrainMaterial;
		if (_terrainMaterial == null && !string.IsNullOrEmpty(oldValue))
		{
		    //Debug.Log("Loading terrain material at: " + oldValue);
		    _terrainMaterial = HEU_MaterialFactory.LoadUnityMaterial(oldValue);
		}

		Material newMaterial = EditorGUILayout.ObjectField("Default Terrain Material", _terrainMaterial, typeof(Material), false) as Material;
		if (newMaterial != _terrainMaterial)
		{
		    string materialPath = "";
		    if (newMaterial != null)
		    {
			materialPath = HEU_AssetDatabase.GetAssetPathWithSubAssetSupport(newMaterial);
			if (!string.IsNullOrEmpty(materialPath) && (materialPath.StartsWith(HEU_Defines.DEFAULT_UNITY_BUILTIN_RESOURCES)))
			{
			    // Default materials need to be specially handled
			    materialPath = HEU_AssetDatabase.GetUniqueAssetPathForUnityAsset(newMaterial);
			    newMaterial = HEU_AssetDatabase.LoadUnityAssetFromUniqueAssetPath<Material>(materialPath);
			}
		    }

		    HEU_PluginSettings.DefaultTerrainMaterial = materialPath;
		    _terrainMaterial = newMaterial;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.TerrainSplatTextureDefault;
		string newValue = EditorGUILayout.DelayedTextField("Default Terrain Splat Texture", oldValue);
		if (!newValue.Equals(oldValue))
		{
		    HEU_PluginSettings.TerrainSplatTextureDefault = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.DefaultStandardShader;
		string newValue = EditorGUILayout.DelayedTextField("Default Standard Shader", oldValue);
		if (!newValue.Equals(oldValue))
		{
		    HEU_PluginSettings.DefaultStandardShader = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.DefaultTransparentShader;
		string newValue = EditorGUILayout.DelayedTextField("Default Transparent Shader", oldValue);
		if (!newValue.Equals(oldValue))
		{
		    HEU_PluginSettings.DefaultTransparentShader = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.DefaultVertexColorShader;
		string newValue = EditorGUILayout.DelayedTextField("Default Vertex Color Shader", oldValue);
		if (!newValue.Equals(oldValue))
		{
		    HEU_PluginSettings.DefaultVertexColorShader = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.DefaultCurveShader;
		string newValue = EditorGUILayout.DelayedTextField("Default Curve Shader", oldValue);
		if (!newValue.Equals(oldValue))
		{
		    HEU_PluginSettings.DefaultCurveShader = newValue;
		    bChanged = true;
		}
	    }

	    HEU_EditorUI.DrawSeparator();

	    EditorGUIUtility.labelWidth = 0;

	    return bChanged;
	}
예제 #10
0
	private bool DrawSessionSettings()
	{
	    bool bChanged = false;

	    HEU_EditorUI.DrawSeparator();

	    EditorGUIUtility.labelWidth = 250;
	    {
		string oldValue = HEU_PluginSettings.Session_PipeName;
		string newValue = EditorGUILayout.DelayedTextField("Pipe Session Name", oldValue);
		if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
		{
		    HEU_PluginSettings.Session_PipeName = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		string oldValue = HEU_PluginSettings.Session_Localhost;
		string newValue = EditorGUILayout.DelayedTextField("Socket Session Host Name", oldValue);
		if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
		{
		    HEU_PluginSettings.Session_Localhost = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		int oldValue = HEU_PluginSettings.Session_Port;
		int newValue = EditorGUILayout.DelayedIntField("Socket Session Port", oldValue);
		if (oldValue != newValue)
		{
		    HEU_PluginSettings.Session_Port = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		float oldValue = HEU_PluginSettings.Session_Timeout;
		float newValue = EditorGUILayout.DelayedFloatField("Session Timeout", oldValue);
		if (oldValue != newValue)
		{
		    HEU_PluginSettings.Session_Timeout = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		bool oldValue = HEU_PluginSettings.Session_AutoClose;
		bool newValue = EditorGUILayout.Toggle("Session Auto Close", oldValue);
		if (oldValue != newValue)
		{
		    HEU_PluginSettings.Session_AutoClose = newValue;
		    bChanged = true;
		}
	    }

	    EditorGUIUtility.labelWidth = 0;

	    return bChanged;
	}
예제 #11
0
	private bool DrawDetailsGeneral()
	{
	    bool bChanged = false;
	    {
		string oldPath = HEU_PluginSettings.AssetCachePath;
		EditorGUILayout.LabelField(new GUIContent("Houdini Asset Cache Path:", "Files generated by this plugin will be stored in this folder path relative to Assets/."));
		string newPath = EditorGUILayout.TextField("", oldPath);
		if (!newPath.Equals(oldPath))
		{
		    HEU_PluginSettings.AssetCachePath = newPath;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
#if UNITY_EDITOR_WIN
	    // Only enabling this for Windows since Mac/Linux have issues dynamically loading
	    // HAPI libraries.
	    {
		string oldPath = HEU_PluginSettings.HoudiniInstallPath;
		string fileExt = "";

		EditorGUILayout.LabelField(new GUIContent("Override Houdini Install Path:",
			"Set a specific Houdini installation to use for this plugin. The plugin's default version of Houdini will be ignored."));
		using (new EditorGUILayout.HorizontalScope())
		{
		    string newPath = EditorGUILayout.DelayedTextField(oldPath);

		    GUIStyle buttonStyle = HEU_EditorUI.GetNewButtonStyle_MarginPadding(0, 0);
		    if (GUILayout.Button("...", buttonStyle, GUILayout.Width(30), GUILayout.Height(18)))
		    {
			string panelMsg = "Select Houdini Install Path";
			panelMsg += " (.app)";

			string openFilePath = UnityEditor.EditorUtility.OpenFolderPanel(panelMsg, newPath, fileExt);
			if (!string.IsNullOrEmpty(openFilePath))
			{
			    newPath = openFilePath;
			}
		    }

		    if (!newPath.Equals(oldPath))
		    {
			string msgPath = !string.IsNullOrEmpty(newPath) ? newPath : HEU_Platform.GetHoudiniEngineDefaultPath();

			string confirmMsg = string.Format(
				"Change the Houdini install path?\n"
				+ "  New path: {0}\n\n"
				+ "You will need to restart Unity to use this path!", msgPath);

			bool result = HEU_EditorUtility.DisplayDialog("Houdini Install Path Changed", confirmMsg, "Confirm", "Cancel");
			if (result)
			{
			    HEU_PluginSettings.HoudiniInstallPath = newPath;
			    bChanged = true;
			}
		    }
		}
#if UNITY_EDITOR_OSX
				GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
				labelStyle.wordWrap = true;
				EditorGUILayout.LabelField("  On macOS, you'll need to select the path to the .app folder.\n  E.g. /Applications/Houdini/Houdini16.5.616/Houdini Core 16.5.616.app", labelStyle);
#endif
	    }
	    HEU_EditorUI.DrawSeparator();
#endif
	    {
		string oldPath = HEU_PluginSettings.HoudiniDebugLaunchPath;
		string fileExt = "";

		EditorGUILayout.LabelField(new GUIContent("Houdini Debug Executable:", "Set Houdini executable to launch when opening debug scenes."));
		using (new EditorGUILayout.HorizontalScope())
		{
		    string newPath = EditorGUILayout.DelayedTextField(oldPath);

		    GUIStyle buttonStyle = HEU_EditorUI.GetNewButtonStyle_MarginPadding(0, 0);
		    if (GUILayout.Button("...", buttonStyle, GUILayout.Width(30), GUILayout.Height(18)))
		    {
			string panelMsg = "Select Houdini Executable";
#if UNITY_EDITOR_OSX
						panelMsg += " (.app)";
#endif

			string openFilePath = UnityEditor.EditorUtility.OpenFilePanel(panelMsg, newPath, fileExt);
			if (!string.IsNullOrEmpty(openFilePath))
			{
			    newPath = openFilePath;
			}
		    }

		    if (!newPath.Equals(oldPath))
		    {
			HEU_PluginSettings.HoudiniDebugLaunchPath = newPath;
			bChanged = true;
		    }
		}
#if UNITY_EDITOR_OSX
		GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
		labelStyle.wordWrap = true;
		EditorGUILayout.LabelField("  On macOS, you'll need to select the path to the .app folder.\n  E.g. /Applications/Houdini/Houdini18.0.100/Houdini Core 18.0.100.app", labelStyle);
#endif
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		bool oldValue = HEU_PluginSettings.UseFullPathNamesForOutput;
		bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Use Full Path Names For Output");
		if (!newValue.Equals(oldValue))
		{
		    HEU_PluginSettings.UseFullPathNamesForOutput = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		bool oldValue = HEU_PluginSettings.SetCurrentThreadToInvariantCulture;
		bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Set Current Thread To Invariant Culture", "Enabling this sets to use InvariantCutulre which fixes locale-specific parsing issues such as using comma instead of dot for decimals.");
		if (!newValue.Equals(oldValue))
		{
		    HEU_PluginSettings.SetCurrentThreadToInvariantCulture = newValue;
		    bChanged = true;
		}
	    }

	    return bChanged;
	}
예제 #12
0
        public override void OnInspectorGUI()
        {
            var profileAsset = (IvyProfileAsset)target;
            var ivyProfile   = profileAsset.ivyProfile;

            var content = new GUIContent();

            if (!viewedFromMonobehavior)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUILayout.HelpBox("This is an Ivy Profile, it controls how your ivy will look. But to paint anything, you must use an Ivy Behavior on a game object.", MessageType.Info);
                if (GUILayout.Button("Create new Ivy Game Object in Scene"))
                {
                    IvyCore.CreateNewIvyGameObject(profileAsset);
                }
                EditorGUILayout.EndVertical();
                IvyEditor.DrawUILine();
            }

            if (!ivyProfile.showAdvanced)
            {
                EditorGUILayout.HelpBox("Hover over each label to learn more.\nIf you mess up, click Reset To Defaults.", MessageType.Info);
            }

            content = new GUIContent("Reset to Defaults", "This will set almost all ivy settings back to their default settings, which has been tested to work OK.");
            if (GUILayout.Button(content, EditorStyles.miniButton))
            {
                if (EditorUtility.DisplayDialog("Hedera: Reset Ivy Profile to Default Settings", "Are you sure you want to reset this ivy profile back to default settings?", "Yes, reset!", "Cancel"))
                {
                    Undo.RegisterCompleteObjectUndo(profileAsset, "Hedera > Reset Settings");
                    ivyProfile.ResetSettings();
                    ivyProfile.branchMaterial = IvyCore.TryToFindDefaultBranchMaterial();
                    ivyProfile.leafMaterial   = IvyCore.TryToFindDefaultLeafMaterial();
                    EditorUtility.SetDirty(profileAsset);
                }
            }
            EditorGUILayout.Space();
            content = new GUIContent(" Show Extra Settings", "If enabled, exposes ALL the ivy settings for customization, which can be ovewhelming at first.\n(default: false)");
            ivyProfile.showAdvanced = EditorGUILayout.ToggleLeft(content, ivyProfile.showAdvanced);

            EditorGUILayout.Space();
            GUI.changed = false;
            EditorGUI.indentLevel++;
            EditorGUI.BeginChangeCheck();

            content = new GUIContent("Growth Sim", "When you paint ivy, it will try to grow on nearby surfaces. These settings control how much it should grow automatically.");
            ivyProfile.showGrowthFoldout = EditorGUILayout.Foldout(ivyProfile.showGrowthFoldout, content, true);

            if (ivyProfile.showGrowthFoldout)
            {
                content = new GUIContent("Length", "Force branches to grow within this min / max range.\n(default: 1.0 - 3.0)");
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(content, GUILayout.MaxWidth(60));
                EditorGUI.indentLevel--;
                ivyProfile.minLength = Mathf.Clamp(EditorGUILayout.DelayedFloatField(ivyProfile.minLength, GUILayout.MaxWidth(28)), 0.01f, ivyProfile.maxLength - 0.01f);
                EditorGUILayout.MinMaxSlider(ref ivyProfile.minLength, ref ivyProfile.maxLength, 0.01f, 10f);
                ivyProfile.maxLength = Mathf.Clamp(EditorGUILayout.DelayedFloatField(ivyProfile.maxLength, GUILayout.MaxWidth(28)), ivyProfile.minLength + 0.01f, 10f);
                EditorGUI.indentLevel++;
                EditorGUILayout.EndHorizontal();

                content = new GUIContent("Branch Chance %", "The probability a branch can make another branch. Higher values = many more branches. At 100%, most plants will reach their Max Branch Limit.\n(default: 25%");
                ivyProfile.branchingProbability = EditorGUILayout.IntSlider(content, Mathf.RoundToInt(ivyProfile.branchingProbability * 100f), 0, 100) * 0.01f;

                if (ivyProfile.showAdvanced)
                {
                    EditorGUILayout.Space();
                    EditorGUI.indentLevel++;
                    EditorGUILayout.LabelField("EXTRA GROW OPTIONS", EditorStyles.miniLabel);

                    content = new GUIContent("Max Branches", "Maximum total branches allowed per plant, basically how much the plant will spread. (Hint: If you want ivy to go specific places, then paint multiple plants and merge them.)\n(default: 64)");
                    ivyProfile.maxBranchesTotal = EditorGUILayout.IntSlider(content, ivyProfile.maxBranchesTotal, 1, 256);

                    content = new GUIContent("Step Distance", "How far ivy tries to move per frame, the simulation resolution. (default: 0.1)\nSmaller = more curvy, smoother, more polygons.\nLarger = more angular and fewer polygons.");
                    ivyProfile.ivyStepDistance = EditorGUILayout.Slider(content, ivyProfile.ivyStepDistance, 0.01f, 0.5f);

                    content = new GUIContent("Float Length", "How far ivy can 'float' with no surface to cling on to.\n(default: 1)");
                    ivyProfile.maxFloatLength = EditorGUILayout.Slider(content, ivyProfile.maxFloatLength, 0.001f, 2f);

                    content = new GUIContent("Cling Distance", "How far ivy can detect surfaces to cling on to. Larger values make ivy 'smarter', but simulation will be slower and more expensive.\n(default: 1.0)");
                    ivyProfile.maxAdhesionDistance = EditorGUILayout.Slider(content, ivyProfile.maxAdhesionDistance, 0.01f, 2f);

                    content = new GUIContent("Collision Mask", "Which layers the ivy should collide with / cling to. Also determines which collision layers you can paint on.\n(default: Everything except Ignore Raycast)");
                    ivyProfile.collisionMask = EditorGUILayout.MaskField(content, InternalEditorUtility.LayerMaskToConcatenatedLayersMask(ivyProfile.collisionMask), InternalEditorUtility.layers);

                    if (ivyProfile.collisionMask == 0)
                    {
                        EditorGUILayout.HelpBox("Collision Mask shouldn't be Nothing. That means you can't paint on anything, and ivy can't cling or climb.", MessageType.Warning);
                    }

                    EditorGUI.indentLevel--;
                    EditorGUILayout.Space();
                }
            }

            IvyEditor.DrawUILine();
            // =========

            content = new GUIContent("Growth AI", "When you simulate ivy, it will try new growth directions using these influence settings.");
            ivyProfile.showAIFoldout = EditorGUILayout.Foldout(ivyProfile.showAIFoldout, content, true);

            if (ivyProfile.showAIFoldout)
            {
                content = new GUIContent("Random Spread %", "How much to randomly roam outwards in different directions. At 100%, ivy will spread out to cover more of an area.\n(default: 100%)");
                ivyProfile.randomWeight = EditorGUILayout.IntSlider(content, Mathf.RoundToInt(ivyProfile.randomWeight * 100f), 0, 400) * 0.01f;

                if (ivyProfile.showAdvanced)
                {
                    EditorGUILayout.Space();
                    EditorGUI.indentLevel++;
                    EditorGUILayout.LabelField("EXTRA AI OPTIONS", EditorStyles.miniLabel);

                    content = new GUIContent("Plant Follow %", "How much to maintain current path and/or grow upwards toward the sun.\n(default: 50%)");
                    ivyProfile.primaryWeight = EditorGUILayout.IntSlider(content, Mathf.RoundToInt(ivyProfile.primaryWeight * 100f), 0, 400) * 0.01f;

                    content = new GUIContent("Gravity Weight %", "How much gravity should pull down floating branches.\n(default: 300%)");
                    ivyProfile.gravityWeight = EditorGUILayout.IntSlider(content, Mathf.RoundToInt(ivyProfile.gravityWeight * 100f), 0, 400) * 0.01f;

                    content = new GUIContent("Surface Cling %", "How much to cling / adhere to nearby surfaces.\n(default: 100%)");
                    ivyProfile.adhesionWeight = EditorGUILayout.IntSlider(content, Mathf.RoundToInt(ivyProfile.adhesionWeight * 100f), 0, 400) * 0.01f;

                    EditorGUI.indentLevel--;
                    EditorGUILayout.Space();
                }
            }

            IvyEditor.DrawUILine();
            // =========

            content = new GUIContent("3D Mesh Settings", "After ivy is done growing, you can make a 3D mesh model based on its path. These settings control how the ivy 3D model will look.");
            ivyProfile.showMeshFoldout = EditorGUILayout.Foldout(ivyProfile.showMeshFoldout, content, true);

            if (ivyProfile.showMeshFoldout)
            {
                content = new GUIContent("Branch Thickness", "Width (diameter) of the branch meshes in world units. (default: 0.05)");
                ivyProfile.ivyBranchSize = EditorGUILayout.Slider(content, ivyProfile.ivyBranchSize, 0f, 0.5f);

                if (ivyProfile.ivyBranchSize == 0f)
                {
                    EditorGUILayout.HelpBox("No branches when Thickness is 0", MessageType.Warning);
                }

                content = new GUIContent("Leaf Size Radius", "Radial size of leaves in world units. Smaller leaves = more leaves (to maintain the same % of coverage) which means more polygons, so bigger leaves are usually better for performance.\n(default: 0.15)");
                ivyProfile.ivyLeafSize = EditorGUILayout.Slider(content, ivyProfile.ivyLeafSize, 0.05f, 1f);

                content = new GUIContent("Leaf Density %", "How many leaves on each branch. 0% means no leaves, 100% is very bushy.\n(default: 50%)");
                ivyProfile.leafProbability = EditorGUILayout.IntSlider(content, Mathf.RoundToInt(ivyProfile.leafProbability * 100f), 0, 100) * 0.01f;

                if (ivyProfile.leafProbability == 0f)
                {
                    EditorGUILayout.HelpBox("No leaves when Leaf Density is 0%", MessageType.Warning);
                }

                content = new GUIContent("Vertex Colors", "Randomize leaf mesh's vertex colors, based on a gradient. Make sure your leaf material's shader supports vertex colors, and the default Hedera foliage shader supports vertex colors. If disabled then no vertex colors will be generated, which saves memory.\n(default: true)");
                ivyProfile.useVertexColors = EditorGUILayout.Toggle(content, ivyProfile.useVertexColors);
                if (ivyProfile.useVertexColors)
                {
                    content = new GUIContent("Leaf Colors", "Leaves will pick random vertex colors anywhere along this gradient.\n(default: white > green > yellow)");
                    #if UNITY_2017_1_OR_NEWER
                    EditorGUI.indentLevel++;
                    ivyProfile.leafVertexColors = EditorGUILayout.GradientField(content, ivyProfile.leafVertexColors);
                    EditorGUI.indentLevel--;
                    #else
                    EditorGUILayout.HelpBox("Can't display gradient editor in Unity 5.6 or earlier, for boring reasons. You'll have to edit the gradient in debug inspector.", MessageType.Error);
                    // ivyProfile.leafVertexColors.colorKeys[0].color = EditorGUILayout.ColorField( content, ivyProfile.leafVertexColors.colorKeys[0].color );
                    #endif
                }

                content = new GUIContent("Branch Material", "Unity material to use for branches. It doesn't need to be very high resolution or detailed, unless you set your Branch Thickness to be very wide. Example materials can be found in /Hedera/Runtime/Materials/");
                ivyProfile.branchMaterial = EditorGUILayout.ObjectField(content, ivyProfile.branchMaterial, typeof(Material), false) as Material;

                if (ivyProfile.branchMaterial == null)
                {
                    EditorGUILayout.HelpBox("Branch Material is undefined. Branch meshes will use default material.", MessageType.Warning);
                }

                content = new GUIContent("Leaf Material", "Unity material to use for leaves. Example materials are in /Hedera/Runtime/Materials/");
                ivyProfile.leafMaterial = EditorGUILayout.ObjectField(content, ivyProfile.leafMaterial, typeof(Material), false) as Material;

                if (ivyProfile.leafMaterial == null)
                {
                    EditorGUILayout.HelpBox("Leaf Material is undefined. Leaf meshes will use default material.", MessageType.Warning);
                }

                if (ivyProfile.showAdvanced)
                {
                    EditorGUILayout.Space();
                    EditorGUI.indentLevel++;
                    EditorGUILayout.LabelField("EXTRA MESH OPTIONS", EditorStyles.miniLabel);

                    content = new GUIContent("Name Format", "All 3D ivy object names use this template, with numbered placeholders to fill-in data.\n{0}: branch count\n{1}: seed position\n(default: 'Ivy[{0}]{1}')");
                    ivyProfile.namePrefix = EditorGUILayout.DelayedTextField(content, ivyProfile.namePrefix);

                    content = new GUIContent("Batching Static", "Set ivy meshes to 'batch' draw calls for huge performance gains. Always enable this unless you're moving / rotating / scaling the ivy during the game.\n(default: true)");
                    ivyProfile.markMeshAsStatic = EditorGUILayout.Toggle(content, ivyProfile.markMeshAsStatic);

                    content = new GUIContent("Lighting Static", "Set ivy meshes to use lightmapping AND generate lightmap UV2s for the ivy.\n- Make sure your lightmap luxel resolution is high enough, or else it'll probably look very spotty.\n- Also make sure your lightmap atlas size is big enough, or else the lightmapped ivy won't batch.\n- If disabled, meshes won't have UV2s, which saves memory.\n(default: false)");
                    ivyProfile.useLightmapping = EditorGUILayout.Toggle(content, ivyProfile.useLightmapping);

                    content = new GUIContent("Mesh Compress", "How much to compress ivy meshes for a smaller file size in the build. However, higher compression can introduce small flaws or glitches in the mesh.\n(default: Low)");
                    ivyProfile.meshCompress = (IvyProfile.MeshCompression)EditorGUILayout.EnumPopup(content, ivyProfile.meshCompress);

                    content = new GUIContent("Cast Shadows", "The Cast Shadows setting on the ivy mesh renderers.\n(default: On)");
                    ivyProfile.castShadows = (UnityEngine.Rendering.ShadowCastingMode)EditorGUILayout.EnumPopup(content, ivyProfile.castShadows);

                    content = new GUIContent("Receive Shadow", "The Receive Shadows setting on the ivy mesh renderers.\n(default: True)");
                    ivyProfile.receiveShadows = EditorGUILayout.Toggle(content, ivyProfile.receiveShadows);

                    content = new GUIContent("Smooth Count", "How many Catmull-Rom spline subdivisions to add to each branch to smooth out the line. For example, a value of 2 doubles your branch vert count.\n- Don't set it too high, and make sure you set Simplify above 0%.\n- value of 1 means no smoothing.\n(default: 2)");
                    ivyProfile.branchSmooth = EditorGUILayout.IntSlider(content, ivyProfile.branchSmooth, 1, 4);

                    content = new GUIContent("Simplify %", "How much to optimize branch meshes, to try to retain the main shape with fewer segments. High percentages will lower verts and polycounts for branches, but might look jagged or lose small details. 0% means no optimization will happen.\n(default: 50%)");
                    ivyProfile.branchOptimize = EditorGUILayout.IntSlider(content, Mathf.RoundToInt(ivyProfile.branchOptimize * 100f), 0, 100) * 0.01f;

                    content = new GUIContent("Taper %", "How much to taper / sharpen branch mesh ends. Looks great for organic objects. But for ropes, cables, or pipes, you should set to 0% to maintain a constant thickness.\n(default: 100%)");
                    ivyProfile.branchTaper = EditorGUILayout.IntSlider(content, Mathf.RoundToInt(ivyProfile.branchTaper * 100f), 0, 100) * 0.01f;

                    content = new GUIContent("Leaf Sunlight %", "Approximates how ivy wants to be in the sun. Leaves will face upwards more. Ivy will grow more leaves on floors / roofs, and fewer leaves on ceilings. 0% means leaves will spawn evenly regardless of surface, and align leaves with surface.\n(default: 100%)");
                    ivyProfile.leafSunlightBonus = EditorGUILayout.IntSlider(content, Mathf.RoundToInt(ivyProfile.leafSunlightBonus * 100f), 0, 100) * 0.01f;

                    EditorGUI.indentLevel--;
                    EditorGUILayout.Space();
                }
            }

            EditorGUI.indentLevel--;

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(profileAsset, "Hedera > Edit Ivy Settings");
                EditorUtility.SetDirty(profileAsset);
            }

            EditorGUILayout.Space();
        }
        private void DrawShadingOverrideGUI()
        {
            string label = "Shading Override";
            string id    = "shadingoverride" + instance.GetInstanceID();

            GenericMenu context = new GenericMenu();

            context.AddItem(
                new GUIContent("Default"),
                false,
                () =>
            {
                instance.ResetShading();
            });
            context.AddSeparator(null);
            context.AddItem(
                new GUIContent("Reset"),
                false,
                () =>
            {
                GCommon.ForEachTerrain(
                    instance.GroupId,
                    (t) =>
                {
                    if (t.TerrainData == null)
                    {
                        return;
                    }
                    t.TerrainData.Shading.ResetFull();
                });
            });
            context.AddItem(
                new GUIContent("Refresh"),
                false,
                () =>
            {
                GCommon.ForEachTerrain(
                    instance.GroupId,
                    (t) =>
                {
                    if (t.TerrainData == null)
                    {
                        return;
                    }
                    t.TerrainData.Shading.UpdateLookupTextures();
                    t.TerrainData.Shading.UpdateMaterials();
                });
            });
            context.AddItem(
                new GUIContent("Set Shader"),
                false,
                () =>
            {
                GTerrainWizardWindow.ShowWindowSetShaderForTerrainGroupMode(instance.GroupId);
            });


            GEditorCommon.Foldout(label, false, id, () =>
            {
                EditorGUI.indentLevel -= 1;
                GShadingOverride s     = instance.ShadingOverride;
                EditorGUI.BeginChangeCheck();
                float labelWidth            = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = labelWidth - TOGGLE_WIDTH;
                EditorGUILayout.BeginHorizontal();
                s.OverrideCustomMaterial = EditorGUILayout.Toggle(s.OverrideCustomMaterial, GUILayout.Width(TOGGLE_WIDTH));
                s.CustomMaterial         = EditorGUILayout.ObjectField("Material Template", s.CustomMaterial, typeof(Material), false) as Material;
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideAlbedoMapResolution = EditorGUILayout.Toggle(s.OverrideAlbedoMapResolution, GUILayout.Width(TOGGLE_WIDTH));
                s.AlbedoMapResolution         = EditorGUILayout.DelayedIntField("Albedo Map Resolution", s.AlbedoMapResolution);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideMetallicMapResolution = EditorGUILayout.Toggle(s.OverrideMetallicMapResolution, GUILayout.Width(TOGGLE_WIDTH));
                s.MetallicMapResolution         = EditorGUILayout.DelayedIntField("Metallic Map Resolution", s.MetallicMapResolution);
                EditorGUILayout.EndHorizontal();

                SerializedObject so   = new SerializedObject(instance);
                SerializedProperty sp = so.FindProperty("shadingOverride");

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorByNormal     = EditorGUILayout.Toggle(s.OverrideColorByNormal, GUILayout.Width(TOGGLE_WIDTH));
                SerializedProperty cbnProps = sp.FindPropertyRelative("colorByNormal");
                EditorGUILayout.PropertyField(cbnProps);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorBlendCurve = EditorGUILayout.Toggle(s.OverrideColorBlendCurve, GUILayout.Width(TOGGLE_WIDTH));
                s.ColorBlendCurve         = EditorGUILayout.CurveField("Blend By Height", s.ColorBlendCurve, Color.red, new Rect(0, 0, 1, 1));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorByHeight     = EditorGUILayout.Toggle(s.OverrideColorByHeight, GUILayout.Width(TOGGLE_WIDTH));
                SerializedProperty cbhProps = sp.FindPropertyRelative("colorByHeight");
                EditorGUILayout.PropertyField(cbhProps);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplats = EditorGUILayout.Toggle(s.OverrideSplats, GUILayout.Width(TOGGLE_WIDTH));
                s.Splats         = EditorGUILayout.ObjectField("Splats", s.Splats, typeof(GSplatPrototypeGroup), false) as GSplatPrototypeGroup;
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatControlResolution = EditorGUILayout.Toggle(s.OverrideSplatControlResolution, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatControlResolution         = EditorGUILayout.DelayedIntField("Splat Control Maps Resolution", s.SplatControlResolution);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideAlbedoMapPropertyName = EditorGUILayout.Toggle(s.OverrideAlbedoMapPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.AlbedoMapPropertyName         = EditorGUILayout.DelayedTextField("Albedo Map Property Name", s.AlbedoMapPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideMetallicMapPropertyName = EditorGUILayout.Toggle(s.OverrideMetallicMapPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.MetallicMapPropertyName         = EditorGUILayout.DelayedTextField("Metallic Map Property Name", s.MetallicMapPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorByHeightPropertyName = EditorGUILayout.Toggle(s.OverrideColorByHeightPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.ColorByHeightPropertyName         = EditorGUILayout.DelayedTextField("Color By Height Property Name", s.ColorByHeightPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorByNormalPropertyName = EditorGUILayout.Toggle(s.OverrideColorByNormalPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.ColorByNormalPropertyName         = EditorGUILayout.DelayedTextField("Color By Normal Property Name", s.ColorByNormalPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorBlendPropertyName = EditorGUILayout.Toggle(s.OverrideColorBlendPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.ColorBlendPropertyName         = EditorGUILayout.DelayedTextField("Color Blend Property Name", s.ColorBlendPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideDimensionPropertyName = EditorGUILayout.Toggle(s.OverrideDimensionPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.DimensionPropertyName         = EditorGUILayout.DelayedTextField("Dimension Property Name", s.DimensionPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatControlMapPropertyName = EditorGUILayout.Toggle(s.OverrideSplatControlMapPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatControlMapPropertyName         = EditorGUILayout.DelayedTextField("Splat Control Map Property Name", s.SplatControlMapPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatMapPropertyName = EditorGUILayout.Toggle(s.OverrideSplatMapPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatMapPropertyName         = EditorGUILayout.DelayedTextField("Splat Map Property Name", s.SplatMapPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatNormalPropertyName = EditorGUILayout.Toggle(s.OverrideSplatNormalPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatNormalPropertyName         = EditorGUILayout.DelayedTextField("Splat Normal Property Name", s.SplatNormalPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatMetallicPropertyName = EditorGUILayout.Toggle(s.OverrideSplatMetallicPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatMetallicPropertyName         = EditorGUILayout.DelayedTextField("Splat Metallic Property Name", s.SplatMetallicPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatSmoothnessPropertyName = EditorGUILayout.Toggle(s.OverrideSplatSmoothnessPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatSmoothnessPropertyName         = EditorGUILayout.DelayedTextField("Splat Smoothness Property Name", s.SplatSmoothnessPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUIUtility.labelWidth = labelWidth;

                if (EditorGUI.EndChangeCheck())
                {
                    so.ApplyModifiedProperties();
                    instance.ShadingOverride = s;
                    if (!instance.DeferredUpdate)
                    {
                        GAnalytics.Record(GAnalytics.GROUP_OVERRIDE_SHADING);
                        instance.OverrideShading();
                    }
                }
                so.Dispose();
                sp.Dispose();
                cbhProps.Dispose();
                cbnProps.Dispose();
                EditorGUI.indentLevel += 1;
            }, context);
        }
        void DrawFilters()
        {
            EditorGUILayout.BeginVertical(GUI.skin.box, GUILayout.ExpandWidth(true));

            m_Preferences.filters = BoldFoldout(m_Preferences.filters, Styles.FiltersFoldout);
            if (m_Preferences.filters)
            {
                EditorGUI.indentLevel++;

                DrawAssemblyFilter();
                DrawAreaFilter();

                EditorGUI.BeginChangeCheck();

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(Styles.TextSearchLabel, GUILayout.Width(80));

                m_TextFilter.searchText = EditorGUILayout.DelayedTextField(m_TextFilter.searchText, GUILayout.Width(180));
                activeAnalysisView.table.searchString = m_TextFilter.searchText;

                m_TextFilter.matchCase = EditorGUILayout.ToggleLeft(Styles.TextSearchCaseSensitive, m_TextFilter.matchCase, GUILayout.Width(160));

                if (m_DeveloperMode)
                {
                    // this is only available in developer mode because it is still too slow at the moment
                    GUI.enabled = activeAnalysisView.desc.showDependencyView;
                    m_TextFilter.searchDependencies = EditorGUILayout.ToggleLeft("Call Tree (slow)",
                                                                                 m_TextFilter.searchDependencies, GUILayout.Width(160));
                    GUI.enabled = true;
                }

                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Show :", GUILayout.ExpandWidth(true), GUILayout.Width(80));
                GUI.enabled = activeAnalysisView.desc.showCritical;

                bool wasShowingCritical = m_Preferences.onlyCriticalIssues;
                m_Preferences.onlyCriticalIssues = EditorGUILayout.ToggleLeft("Only Critical Issues",
                                                                              m_Preferences.onlyCriticalIssues, GUILayout.Width(160));
                GUI.enabled = true;

                if (wasShowingCritical != m_Preferences.onlyCriticalIssues)
                {
                    var analytic = ProjectAuditorAnalytics.BeginAnalytic();
                    var payload  = new Dictionary <string, string>();
                    payload["selected"] = activeAnalysisView.desc.showCritical ? "true" : "false";
                    ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.OnlyCriticalIssues,
                                                              analytic);
                }

                bool wasDisplayingMuted = m_Preferences.mutedIssues;
                m_Preferences.mutedIssues = EditorGUILayout.ToggleLeft("Muted Issues",
                                                                       m_Preferences.mutedIssues, GUILayout.Width(127));

                if (wasDisplayingMuted != m_Preferences.mutedIssues)
                {
                    var analytic = ProjectAuditorAnalytics.BeginAnalytic();
                    var payload  = new Dictionary <string, string>();
                    payload["selected"] = m_Preferences.mutedIssues ? "true" : "false";
                    ProjectAuditorAnalytics.SendUIButtonEventWithKeyValues(ProjectAuditorAnalytics.UIButton.ShowMuted,
                                                                           analytic, payload);
                }

                EditorGUILayout.EndHorizontal();

                if (EditorGUI.EndChangeCheck())
                {
                    m_ShouldRefresh = true;
                }

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndVertical();
        }
예제 #15
0
        static void VSCodePreferencesItem()
        {
            if (EditorApplication.isCompiling)
            {
                EditorGUILayout.HelpBox("Please wait for Unity to finish compiling. \nIf the window doesn't refresh, simply click on the window or move it around to cause a repaint to happen.", MessageType.Warning);
                return;
            }
            EditorGUILayout.BeginVertical();

            EditorGUILayout.HelpBox("Support development of this plugin, follow @reapazor and @dotbunny on Twitter.", MessageType.Info);

            EditorGUI.BeginChangeCheck();

            Enabled = EditorGUILayout.Toggle(new GUIContent("Enable Integration", "Should the integration work its magic for you?"), Enabled);
#if UNITY_5_3_OR_NEWER
            CodePath = EditorGUILayout.DelayedTextField(new GUIContent("VS Code Path", "Full path to the Micosoft Visual Studio code executable."), CodePath);
#else
            CodePath = EditorGUILayout.TextField(new GUIContent("VS Code Path", "Full path to the Micosoft Visual Studio code executable."), CodePath);
#endif

            UseUnityDebugger = EditorGUILayout.Toggle(new GUIContent("Use Unity Debugger", "Should the integration integrate with Unity's VSCode Extension (must be installed)."), UseUnityDebugger);

            EditorGUILayout.Space();
            RevertExternalScriptEditorOnExit = EditorGUILayout.Toggle(new GUIContent("Revert Script Editor On Unload", "Should the external script editor setting be reverted to its previous setting on project unload? This is useful if you do not use Code with all your projects."), RevertExternalScriptEditorOnExit);

            Debug = EditorGUILayout.Toggle(new GUIContent("Output Messages To Console", "Should informational messages be sent to Unity's Console?"), Debug);

            WriteLaunchFile = EditorGUILayout.Toggle(new GUIContent("Always Write Launch File", "Always write the launch.json settings when entering play mode?"), WriteLaunchFile);

            EditorGUILayout.Space();

            AutomaticUpdates = EditorGUILayout.Toggle(new GUIContent("Automatic Updates", "Should the plugin automatically update itself?"), AutomaticUpdates);

            UpdateTime = EditorGUILayout.IntSlider(new GUIContent("Update Timer (Days)", "After how many days should updates be checked for?"), UpdateTime, 1, 31);

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            if (EditorGUI.EndChangeCheck())
            {
                UpdateUnityPreferences(Enabled);

                //UnityEditor.PreferencesWindow.Read

                // TODO: Force Unity To Reload Preferences
                // This seems to be a hick up / issue

                if (VSCode.Debug)
                {
                    if (Enabled)
                    {
                        UnityEngine.Debug.Log("[VSCode] Integration Enabled");
                    }
                    else
                    {
                        UnityEngine.Debug.Log("[VSCode] Integration Disabled");
                    }
                }
            }

            if (GUILayout.Button(new GUIContent("Force Update", "Check for updates to the plugin, right NOW!")))
            {
                CheckForUpdate();
                EditorGUILayout.EndVertical();
                return;
            }
            if (GUILayout.Button(new GUIContent("Write Workspace Settings", "Output a default set of workspace settings for VSCode to use, ignoring many different types of files.")))
            {
                WriteWorkspaceSettings();
                EditorGUILayout.EndVertical();
                return;
            }
            EditorGUILayout.Space();

            if (UseUnityDebugger)
            {
                EditorGUILayout.HelpBox("In order for the \"Use Unity Debuggger\" option to function above, you need to have installed the Unity Debugger Extension for Visual Studio Code. You can do this by simply clicking the button below and it will take care of the rest.", MessageType.Warning);
                if (GUILayout.Button(new GUIContent("Install Unity Debugger", "Install the Unity Debugger Extension into Code")))
                {
                    InstallUnityDebugger();
                    EditorGUILayout.EndVertical();
                    return;
                }
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            GUILayout.Label(
                new GUIContent(
                    string.Format("{0:0.00}", Version) + VersionCode,
                    "GitHub's Version @ " + string.Format("{0:0.00}", GitHubVersion)));

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }