Exemplo n.º 1
0
    /// <summary>
    /// Draw the label's properties.
    /// </summary>

    protected override bool ShouldDrawProperties()
    {
        mLabel = mWidget as UILabel;

        GUILayout.BeginHorizontal();

#if DYNAMIC_FONT
        mFontType = (FontType)EditorGUILayout.EnumPopup(mFontType, "DropDown", GUILayout.Width(74f));
        if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(64f)))
#else
        mFontType = FontType.NGUI;
        if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(74f)))
#endif
        {
            if (mFontType == FontType.NGUI)
            {
                ComponentSelector.Show <UIFont>(OnNGUIFont);
            }
            else
            {
                ComponentSelector.Show <Font>(OnUnityFont, new string[] { ".ttf", ".otf" });
            }
        }

        bool isValid           = false;
        SerializedProperty fnt = null;
        SerializedProperty ttf = null;

        if (mFontType == FontType.NGUI)
        {
            GUI.changed = false;
            fnt         = NGUIEditorTools.DrawProperty("", serializedObject, "mFont", GUILayout.MinWidth(40f));

            if (fnt.objectReferenceValue != null)
            {
                if (GUI.changed)
                {
                    serializedObject.FindProperty("mTrueTypeFont").objectReferenceValue = null;
                }
                NGUISettings.ambigiousFont = fnt.objectReferenceValue;
                isValid = true;
            }
        }
        else
        {
            GUI.changed = false;
            ttf         = NGUIEditorTools.DrawProperty("", serializedObject, "mTrueTypeFont", GUILayout.MinWidth(40f));

            if (ttf.objectReferenceValue != null)
            {
                if (GUI.changed)
                {
                    serializedObject.FindProperty("mFont").objectReferenceValue = null;
                }
                NGUISettings.ambigiousFont = ttf.objectReferenceValue;
                isValid = true;
            }
        }

        GUILayout.EndHorizontal();

        if (mFontType == FontType.Unity)
        {
            EditorGUILayout.HelpBox("Dynamic fonts suffer from issues in Unity itself where your characters may disappear, get garbled, or just not show at times. Use this feature at your own risk.\n\n" +
                                    "When you do run into such issues, please submit a Bug Report to Unity via Help -> Report a Bug (as this is will be a Unity bug, not an NGUI one).", MessageType.Warning);
        }

        EditorGUI.BeginDisabledGroup(!isValid);
        {
            UIFont uiFont  = (fnt != null) ? fnt.objectReferenceValue as UIFont : null;
            Font   dynFont = (ttf != null) ? ttf.objectReferenceValue as Font : null;

            if (uiFont != null && uiFont.isDynamic)
            {
                dynFont = uiFont.dynamicFont;
                uiFont  = null;
            }

            if (dynFont != null)
            {
                GUILayout.BeginHorizontal();
                {
                    EditorGUI.BeginDisabledGroup((ttf != null) ? ttf.hasMultipleDifferentValues : fnt.hasMultipleDifferentValues);

                    SerializedProperty prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));
                    NGUISettings.fontSize = prop.intValue;

                    prop = NGUIEditorTools.DrawProperty("", serializedObject, "mFontStyle", GUILayout.MinWidth(40f));
                    NGUISettings.fontStyle = (FontStyle)prop.intValue;

                    NGUIEditorTools.DrawPadding();
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();

                NGUIEditorTools.DrawProperty("Material", serializedObject, "mMaterial");
            }
            else if (uiFont != null)
            {
                GUILayout.BeginHorizontal();
                SerializedProperty prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));

                EditorGUI.BeginDisabledGroup(true);
                if (!serializedObject.isEditingMultipleObjects)
                {
                    if (mLabel.overflowMethod == UILabel.Overflow.ShrinkContent)
                    {
                        GUILayout.Label(" Actual: " + mLabel.finalFontSize + "/" + mLabel.defaultFontSize);
                    }
                    else
                    {
                        GUILayout.Label(" Default: " + mLabel.defaultFontSize);
                    }
                }
                EditorGUI.EndDisabledGroup();

                NGUISettings.fontSize = prop.intValue;
                GUILayout.EndHorizontal();
            }

            bool ww = GUI.skin.textField.wordWrap;
            GUI.skin.textField.wordWrap = true;
            SerializedProperty sp = serializedObject.FindProperty("mText");

            if (sp.hasMultipleDifferentValues)
            {
                NGUIEditorTools.DrawProperty("", sp, GUILayout.Height(128f));
            }
            else
            {
                GUIStyle style = new GUIStyle(EditorStyles.textField);
                style.wordWrap = true;

                float height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 100f);
                bool  offset = true;

                if (height > 90f)
                {
                    offset = false;
                    height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 20f);
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.BeginVertical(GUILayout.Width(76f));
                    GUILayout.Space(3f);
                    GUILayout.Label("Text");
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical();
                }
                Rect rect = EditorGUILayout.GetControlRect(GUILayout.Height(height));

                GUI.changed = false;
                string text = EditorGUI.TextArea(rect, sp.stringValue, style);
                if (GUI.changed)
                {
                    sp.stringValue = text;
                }

                if (offset)
                {
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
            }

            GUI.skin.textField.wordWrap = ww;

            SerializedProperty ov = NGUIEditorTools.DrawPaddedProperty("Overflow", serializedObject, "mOverflow");
            NGUISettings.overflowStyle = (UILabel.Overflow)ov.intValue;
            if (NGUISettings.overflowStyle == UILabel.Overflow.ClampContent)
            {
                NGUIEditorTools.DrawProperty("Use Ellipsis", serializedObject, "mOverflowEllipsis", GUILayout.Width(110f));
            }

            NGUIEditorTools.DrawPaddedProperty("Alignment", serializedObject, "mAlignment");

            if (dynFont != null)
            {
                NGUIEditorTools.DrawPaddedProperty("Keep crisp", serializedObject, "keepCrispWhenShrunk");
            }

            EditorGUI.BeginDisabledGroup(mLabel.bitmapFont != null && mLabel.bitmapFont.packedFontShader);
            GUILayout.BeginHorizontal();
            SerializedProperty gr = NGUIEditorTools.DrawProperty("Gradient", serializedObject, "mApplyGradient",
                                                                 GUILayout.Width(95f));

            EditorGUI.BeginDisabledGroup(!gr.hasMultipleDifferentValues && !gr.boolValue);
            {
                NGUIEditorTools.SetLabelWidth(30f);
                NGUIEditorTools.DrawProperty("Top", serializedObject, "mGradientTop", GUILayout.MinWidth(40f));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                NGUIEditorTools.SetLabelWidth(50f);
                GUILayout.Space(79f);

                NGUIEditorTools.DrawProperty("Bottom", serializedObject, "mGradientBottom", GUILayout.MinWidth(40f));
                NGUIEditorTools.SetLabelWidth(80f);
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Effect", GUILayout.Width(76f));
            sp = NGUIEditorTools.DrawProperty("", serializedObject, "mEffectStyle", GUILayout.MinWidth(16f));

            EditorGUI.BeginDisabledGroup(!sp.hasMultipleDifferentValues && !sp.boolValue);
            {
                NGUIEditorTools.DrawProperty("", serializedObject, "mEffectColor", GUILayout.MinWidth(10f));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(" ", GUILayout.Width(56f));
                    NGUIEditorTools.SetLabelWidth(20f);
                    NGUIEditorTools.DrawProperty("X", serializedObject, "mEffectDistance.x", GUILayout.MinWidth(40f));
                    NGUIEditorTools.DrawProperty("Y", serializedObject, "mEffectDistance.y", GUILayout.MinWidth(40f));
                    NGUIEditorTools.DrawPadding();
                    NGUIEditorTools.SetLabelWidth(80f);
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            sp = NGUIEditorTools.DrawProperty("Float spacing", serializedObject, "mUseFloatSpacing", GUILayout.Width(100f));

            if (!sp.boolValue)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Spacing", GUILayout.Width(56f));
                NGUIEditorTools.SetLabelWidth(20f);
                NGUIEditorTools.DrawProperty("X", serializedObject, "mSpacingX", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawProperty("Y", serializedObject, "mSpacingY", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawPadding();
                NGUIEditorTools.SetLabelWidth(80f);
                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Spacing", GUILayout.Width(56f));
                NGUIEditorTools.SetLabelWidth(20f);
                NGUIEditorTools.DrawProperty("X", serializedObject, "mFloatSpacingX", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawProperty("Y", serializedObject, "mFloatSpacingY", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawPadding();
                NGUIEditorTools.SetLabelWidth(80f);
                GUILayout.EndHorizontal();
            }

            NGUIEditorTools.DrawProperty("Max Lines", serializedObject, "mMaxLineCount", GUILayout.Width(110f));

            GUILayout.BeginHorizontal();
            sp = NGUIEditorTools.DrawProperty("BBCode", serializedObject, "mEncoding", GUILayout.Width(100f));
            EditorGUI.BeginDisabledGroup(!sp.boolValue || mLabel.bitmapFont == null || !mLabel.bitmapFont.hasSymbols);
            NGUIEditorTools.SetLabelWidth(60f);
            NGUIEditorTools.DrawPaddedProperty("Symbols", serializedObject, "mSymbols");
            NGUIEditorTools.SetLabelWidth(80f);
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }
        EditorGUI.EndDisabledGroup();
        return(isValid);
    }
Exemplo n.º 2
0
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);

            showSettings = CustomGUILayout.ToggleHeader(showSettings, "Global menu settings");
            if (showSettings)
            {
                drawInEditor = EditorGUILayout.Toggle("Preview in Game window?", drawInEditor);
                if (drawInEditor)
                {
                    drawOutlines = EditorGUILayout.Toggle("Draw outlines?", drawOutlines);
                    if (drawOutlines && Application.platform == RuntimePlatform.WindowsEditor)
                    {
                        doWindowsPreviewFix = EditorGUILayout.Toggle("Apply outline offset fix?", doWindowsPreviewFix);
                    }
                }
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Pause background texture:", GUILayout.Width(255f));
                pauseTexture = (Texture2D)CustomGUILayout.ObjectField <Texture2D> (pauseTexture, false, GUILayout.Width(70f), GUILayout.Height(30f), "AC.Kickstarter.menuManager.pauseTexture");
                EditorGUILayout.EndHorizontal();
                scaleTextEffects = CustomGUILayout.Toggle("Scale text effects?", scaleTextEffects, "AC.KickStarter.menuManager.scaleTextEffects");
                globalDepth      = CustomGUILayout.IntField("GUI depth:", globalDepth, "AC.KickStarter.menuManager.globalDepth");
                eventSystem      = (UnityEngine.EventSystems.EventSystem)CustomGUILayout.ObjectField <UnityEngine.EventSystems.EventSystem> ("Event system prefab:", eventSystem, false, "AC.KickStarter.menuManager.eventSystem");

                if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.inputMethod != InputMethod.TouchScreen)
                {
                    EditorGUILayout.Space();
                    keyboardControlWhenPaused        = CustomGUILayout.ToggleLeft("Directly-navigate Menus when paused?", keyboardControlWhenPaused, "AC.KickStarter.menuManager.keyboardControlWhenPaused");
                    keyboardControlWhenDialogOptions = CustomGUILayout.ToggleLeft("Directly-navigate Menus during Conversations?", keyboardControlWhenDialogOptions, "AC.KickStarter.menuManager.keyboardControlWhenDialogOptions");
                    if (eventSystem == null)
                    {
                        disableMouseIfKeyboardControlling = CustomGUILayout.ToggleLeft("Disable mouse when directly-controlling Unity UI Menus?", disableMouseIfKeyboardControlling, "AC.KickStarter.menuManager.disableMouseIfKeyboardControlling");
                    }
                }

                if (AdvGame.GetReferences().settingsManager == null || AdvGame.GetReferences().settingsManager.inputMethod != InputMethod.KeyboardOrController)
                {
                    if (keyboardControlWhenPaused ||
                        keyboardControlWhenDialogOptions ||
                        (eventSystem == null && disableMouseIfKeyboardControlling))
                    {
                        EditorGUILayout.HelpBox("When the 'Input method' is not 'Keyboard Or Controller', direct navigation of Menus is only available for Unity UI-based Menus.", MessageType.Info);
                    }
                }

                if (drawInEditor && KickStarter.menuPreview == null)
                {
                    EditorGUILayout.HelpBox("A GameEngine prefab is required to display menus while editing - please click Organise Room Objects within the Scene Manager.", MessageType.Warning);
                }
                else if (Application.isPlaying)
                {
                    EditorGUILayout.HelpBox("Changes made to the menus will not be registed by the game until the game is restarted.", MessageType.Info);
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            CreateMenusGUI();

            if (selectedMenu != null)
            {
                EditorGUILayout.Space();

                string menuTitle = selectedMenu.title;
                if (menuTitle == "")
                {
                    menuTitle = "(Untitled)";
                }

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);

                showMenuProperties = CustomGUILayout.ToggleHeader(showMenuProperties, "Menu " + selectedMenu.id + ": '" + menuTitle + "' properties");
                if (showMenuProperties)
                {
                    selectedMenu.ShowGUI();
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.Space();

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                showElementList = CustomGUILayout.ToggleHeader(showElementList, "Menu " + selectedMenu.id + ": '" + menuTitle + "' elements");
                if (showElementList)
                {
                    CreateElementsGUI(selectedMenu);
                }
                EditorGUILayout.EndVertical();

                if (selectedMenuElement != null)
                {
                    EditorGUILayout.Space();

                    string elementName = selectedMenuElement.title;
                    if (elementName == "")
                    {
                        elementName = "(Untitled)";
                    }

                    string elementType = "";
                    foreach (string _elementType in elementTypes)
                    {
                        if (selectedMenuElement.GetType().ToString().Contains(_elementType))
                        {
                            elementType = _elementType;
                            break;
                        }
                    }

                    EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                    showElementProperties = CustomGUILayout.ToggleHeader(showElementProperties, elementType + " " + selectedMenuElement.ID + ": '" + elementName + "' properties");
                    if (showElementProperties)
                    {
                        oldVisibility = selectedMenuElement.isVisible;
                        selectedMenuElement.ShowGUIStart(selectedMenu);
                    }
                    else
                    {
                        EditorGUILayout.EndVertical();
                    }
                    if (selectedMenuElement.isVisible != oldVisibility)
                    {
                        if (!Application.isPlaying)
                        {
                            selectedMenu.Recalculate();
                        }
                    }
                }
            }

            if (GUI.changed)
            {
                if (!Application.isPlaying)
                {
                    SaveAllMenus();
                }
                EditorUtility.SetDirty(this);
            }
        }
Exemplo n.º 3
0
        protected override void OnServiceUI()
        {
            using (new SA_WindowBlockWithSpace(new GUIContent("Protecting the User's Privacy")))
            {
                EditorGUILayout.HelpBox("Once you link with iOS 10 you must declare access to any user private data types. " +
                                        "Since by default Unity includes libraries that may access API user private data, " +
                                        "the app info.plist mus contains the key's spsifayed bellow. " +
                                        "How ever user will only see this message if you call API that requires private permission. " +
                                        "If you not using such API, you can leave it as is.", MessageType.Info);



                using (new SA_GuiBeginHorizontal())
                {
                    GUILayout.FlexibleSpace();
                    bool click = m_privacyLink.DrawWithCalcSize();
                    if (click)
                    {
                        Application.OpenURL("https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy?language=objc");
                    }
                }

                ISN_Settings.Instance.CameraUsageDescriptionEnabled = SA_EditorGUILayout.ToggleFiled(CameraUsageDescription, ISN_Settings.Instance.CameraUsageDescriptionEnabled, SA_StyledToggle.ToggleType.EnabledDisabled);
                using (new SA_GuiEnable(ISN_Settings.Instance.CameraUsageDescriptionEnabled))
                {
                    using (new SA_GuiIndentLevel(1))
                    {
                        ISN_Settings.Instance.CameraUsageDescription = EditorGUILayout.TextArea(ISN_Settings.Instance.CameraUsageDescription, SA_PluginSettingsWindowStyles.TextArea, GUILayout.Height(30));
                    }
                }



                EditorGUILayout.Space();
                ISN_Settings.Instance.PhotoLibraryUsageDescriptionEnabled = SA_EditorGUILayout.ToggleFiled(PhotoLibraryUsageDescription, ISN_Settings.Instance.PhotoLibraryUsageDescriptionEnabled, SA_StyledToggle.ToggleType.EnabledDisabled);
                using (new SA_GuiEnable(ISN_Settings.Instance.PhotoLibraryUsageDescriptionEnabled))
                {
                    using (new SA_GuiIndentLevel(1))
                    {
                        ISN_Settings.Instance.PhotoLibraryUsageDescription = EditorGUILayout.TextArea(ISN_Settings.Instance.PhotoLibraryUsageDescription, SA_PluginSettingsWindowStyles.TextArea, GUILayout.Height(30));
                    }
                }



                EditorGUILayout.Space();
                ISN_Settings.Instance.PhotoLibraryAddUsageDescriptionEnabled = SA_EditorGUILayout.ToggleFiled(PhotoLibraryAddUsageDescription, ISN_Settings.Instance.PhotoLibraryAddUsageDescriptionEnabled, SA_StyledToggle.ToggleType.EnabledDisabled);
                using (new SA_GuiEnable(ISN_Settings.Instance.PhotoLibraryAddUsageDescriptionEnabled))
                {
                    using (new SA_GuiIndentLevel(1))
                    {
                        ISN_Settings.Instance.PhotoLibraryAddUsageDescription = EditorGUILayout.TextArea(ISN_Settings.Instance.PhotoLibraryAddUsageDescription, SA_PluginSettingsWindowStyles.TextArea, GUILayout.Height(30));
                    }
                }


                EditorGUILayout.Space();
                ISN_Settings.Instance.MicrophoneUsageDescriptionEnabled = SA_EditorGUILayout.ToggleFiled(MicrophoneUsageDescription, ISN_Settings.Instance.MicrophoneUsageDescriptionEnabled, SA_StyledToggle.ToggleType.EnabledDisabled);
                using (new SA_GuiEnable(ISN_Settings.Instance.MicrophoneUsageDescriptionEnabled))
                {
                    using (new SA_GuiIndentLevel(1))
                    {
                        ISN_Settings.Instance.MicrophoneUsageDescription = EditorGUILayout.TextArea(ISN_Settings.Instance.MicrophoneUsageDescription, SA_PluginSettingsWindowStyles.TextArea, GUILayout.Height(30));
                    }
                }
            }



            using (new SA_WindowBlockWithSpace(new GUIContent("Allowed schemes to query")))
            {
                SA_EditorGUILayout.ReorderablList(ISN_Settings.Instance.ApplicationQueriesSchemes,
                                                  (ISN_UIUrlType scheme) =>
                {
                    return(scheme.Identifier);
                },
                                                  (ISN_UIUrlType scheme) =>
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Identifier");
                    scheme.Identifier = EditorGUILayout.TextField(scheme.Identifier);
                    EditorGUILayout.EndHorizontal();
                },
                                                  () =>
                {
                    ISN_UIUrlType newUlr = new ISN_UIUrlType("url_sheme");
                    ISN_Settings.Instance.ApplicationQueriesSchemes.Add(newUlr);
                });
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Draws the custom inspector.
        /// </summary>
        public override void OnInspectorGUI()
        {
            var item = target as Item;

            if (item == null || serializedObject == null)
            {
                return; // How'd this happen?
            }
            base.OnInspectorGUI();

            // Show all of the fields.
            serializedObject.Update();
            EditorGUI.BeginChangeCheck();

            // Allow the user to assign the item if it isn't already assigned
            if (item.transform.parent == null)
            {
                m_AssignTo = EditorGUILayout.ObjectField("Assign To", m_AssignTo, typeof(GameObject), true) as GameObject;
                var enableGUI = m_AssignTo != null && m_AssignTo.GetComponent <Animator>() != null;
                if (enableGUI)
                {
                    if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(m_AssignTo)))
                    {
                        EditorGUILayout.HelpBox("The character must be located within the scene.", MessageType.Error);
                        enableGUI = false;
                    }
                    else
                    {
                        if (m_AssignTo.GetComponent <Animator>().GetBoneTransform(HumanBodyBones.LeftHand) == null)
                        {
                            // The ItemPlacement component must be specified for generic models.
                            m_ItemPlacement = EditorGUILayout.ObjectField("Item Placement", m_ItemPlacement, typeof(ItemPlacement), true) as ItemPlacement;
                            if (m_ItemPlacement == null)
                            {
                                EditorGUILayout.HelpBox("The ItemPlacement GameObject must be specified for Generic models.", MessageType.Error);
                                enableGUI = false;
                            }
                        }
                        else
                        {
                            m_HandAssignment = (HandAssignment)EditorGUILayout.EnumPopup("Hand", m_HandAssignment);
                        }
                    }
                }

                GUI.enabled = enableGUI;
                if (GUILayout.Button("Assign"))
                {
                    Transform itemPlacement = null;
                    if (m_AssignTo.GetComponent <Animator>().GetBoneTransform(HumanBodyBones.LeftHand) == null)
                    {
                        itemPlacement = m_ItemPlacement.transform;
                    }
                    else
                    {
                        var handTransform = m_AssignTo.GetComponent <Animator>().GetBoneTransform(m_HandAssignment == HandAssignment.Left ? HumanBodyBones.LeftHand : HumanBodyBones.RightHand);
                        itemPlacement = handTransform.GetComponentInChildren <ItemPlacement>().transform;
                    }
                    AssignItem(item.gameObject, itemPlacement);
                }
                GUI.enabled = true;
            }

            var itemTypeProperty = PropertyFromName(serializedObject, "m_ItemType");

            EditorGUILayout.PropertyField(itemTypeProperty);
            if (itemTypeProperty.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("This field is required. The Inventory uses the Item Type to determine the type of item.", MessageType.Error);
            }

            var itemName = PropertyFromName(serializedObject, "m_ItemName");

            EditorGUILayout.PropertyField(itemName);
            if (string.IsNullOrEmpty(itemName.stringValue))
            {
                EditorGUILayout.HelpBox("The Item Name specifies the name of the Animator substate machine. It should not be empty unless you only have one item type.", MessageType.Warning);
            }

            if ((m_CharacterAnimatorFoldout = EditorGUILayout.Foldout(m_CharacterAnimatorFoldout, "Character Animator Options", InspectorUtility.BoldFoldout)))
            {
                EditorGUI.indentLevel++;
                var canAim = PropertyFromName(serializedObject, "m_CanAim");
                EditorGUILayout.PropertyField(canAim);
                if (canAim.boolValue)
                {
                    EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_RequireAim"));
                }
                DrawAnimatorStateSet(item, m_ReorderableListMap, m_ReordableLists, OnListSelectInternal, OnListAddInternal, OnListRemoveInternal, PropertyFromName(serializedObject, "m_DefaultStates"));
                if (canAim.boolValue)
                {
                    DrawAnimatorStateSet(item, m_ReorderableListMap, m_ReordableLists, OnListSelectInternal, OnListAddInternal, OnListRemoveInternal, PropertyFromName(serializedObject, "m_AimStates"));
                }
                if (target is IUseableItem)
                {
                    DrawAnimatorStateSet(item, m_ReorderableListMap, m_ReordableLists, OnListSelectInternal, OnListAddInternal, OnListRemoveInternal, PropertyFromName(serializedObject, "m_UseStates"));
                }
                if (target is IReloadableItem)
                {
                    DrawAnimatorStateSet(item, m_ReorderableListMap, m_ReordableLists, OnListSelectInternal, OnListAddInternal, OnListRemoveInternal, PropertyFromName(serializedObject, "m_ReloadStates"));
                }
                if (target is MeleeWeapon || target is Shield)
                {
                    DrawAnimatorStateSet(item, m_ReorderableListMap, m_ReordableLists, OnListSelectInternal, OnListAddInternal, OnListRemoveInternal, PropertyFromName(serializedObject, "m_RecoilStates"));
                }
                DrawAnimatorStateSet(item, m_ReorderableListMap, m_ReordableLists, OnListSelectInternal, OnListAddInternal, OnListRemoveInternal, PropertyFromName(serializedObject, "m_EquipStates"));
                DrawAnimatorStateSet(item, m_ReorderableListMap, m_ReordableLists, OnListSelectInternal, OnListAddInternal, OnListRemoveInternal, PropertyFromName(serializedObject, "m_UnequipStates"));
                EditorGUI.indentLevel--;
            }

            if ((m_UIFoldout = EditorGUILayout.Foldout(m_UIFoldout, "UI Options", InspectorUtility.BoldFoldout)))
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_ItemSprite"), true);
                EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_RightItemSprite"), true);
                EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_CrosshairsSprite"), true);
                EditorGUI.indentLevel--;
            }

            if ((m_InputFoldout = EditorGUILayout.Foldout(m_InputFoldout, "Input Options", InspectorUtility.BoldFoldout)))
            {
                EditorGUI.indentLevel++;
                if (item is IUseableItem)
                {
                    EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_UseInputName"));
                    if (serializedObject.FindProperty("m_DualWieldUseInputName") != null)
                    {
                        EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_DualWieldUseInputName"));
                    }
                }
                if (item is IReloadableItem)
                {
                    EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_ReloadInputName"));
                }
                if (item is IFlashlightUseable)
                {
                    EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_ToggleFlashlightInputName"));
                }
                if (item is ILaserSightUseable)
                {
                    EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_ToggleLaserSightInputName"));
                }
                EditorGUI.indentLevel--;
            }

            if ((m_GeneralFoldout = EditorGUILayout.Foldout(m_GeneralFoldout, "General Options", InspectorUtility.BoldFoldout)))
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_TwoHandedItem"), true);
                EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_NonDominantHandPosition"), true);
                EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_HolsterTarget"), true);
                EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_ItemPickup"), true);
                EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_AimCameraState"));
                EditorGUILayout.PropertyField(PropertyFromName(serializedObject, "m_CollisionNotification"));
                EditorGUI.indentLevel--;
            }

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(item, "Inspector");
                serializedObject.ApplyModifiedProperties();
                InspectorUtility.SetObjectDirty(item);
            }
        }
Exemplo n.º 5
0
 public void Draw()
 {
     EditorGUILayout.PropertyField(Property);
     EditorGUILayout.HelpBox(Description, MessageType.None);
     EditorGUILayout.Space();
 }
Exemplo n.º 6
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager)
            {
                parameterID = Action.ChooseParameterGUI("Hotspot to change:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    hotspot    = null;
                }
                else
                {
                    hotspot = (Hotspot)EditorGUILayout.ObjectField("Hotspot to change:", hotspot, typeof(Hotspot), true);

                    constantID = FieldToID <Hotspot> (hotspot, constantID);
                    hotspot    = IDToField <Hotspot> (hotspot, constantID, false);
                }

                interactionType = (InteractionType)EditorGUILayout.EnumPopup("Interaction to change:", interactionType);

                if ((!isAssetFile && hotspot != null) || isAssetFile)
                {
                    switch (interactionType)
                    {
                    case InteractionType.Use:
                        if (hotspot == null)
                        {
                            number = EditorGUILayout.IntField("Use interaction:", number);
                        }
                        else if (AdvGame.GetReferences().cursorManager)
                        {
                            // Multiple use interactions
                            if (hotspot.useButtons.Count > 0 && hotspot.provideUseInteraction)
                            {
                                List <string> labelList = new List <string> ();

                                foreach (AC.Button button in hotspot.useButtons)
                                {
                                    labelList.Add(hotspot.useButtons.IndexOf(button) + ": " + AdvGame.GetReferences().cursorManager.GetLabelFromID(button.iconID, 0));
                                }

                                number = EditorGUILayout.Popup("Use interaction:", number, labelList.ToArray());
                            }
                            else
                            {
                                EditorGUILayout.HelpBox("No 'Use' interactions defined!", MessageType.Info);
                            }
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("A Cursor Manager is required.", MessageType.Warning);
                        }
                        break;

                    case InteractionType.Examine:
                        if (hotspot != null && !hotspot.provideLookInteraction)
                        {
                            EditorGUILayout.HelpBox("No 'Examine' interaction defined!", MessageType.Info);
                        }
                        break;

                    case InteractionType.Inventory:
                        if (hotspot == null)
                        {
                            number = EditorGUILayout.IntField("Inventory interaction:", number);
                        }
                        else if (AdvGame.GetReferences().inventoryManager)
                        {
                            if (hotspot.invButtons.Count > 0 && hotspot.provideInvInteraction)
                            {
                                List <string> labelList = new List <string> ();

                                foreach (AC.Button button in hotspot.invButtons)
                                {
                                    labelList.Add(hotspot.invButtons.IndexOf(button) + ": " + AdvGame.GetReferences().inventoryManager.GetLabel(button.invID));
                                }

                                number = EditorGUILayout.Popup("Inventory interaction:", number, labelList.ToArray());
                            }
                            else
                            {
                                EditorGUILayout.HelpBox("No 'Inventory' interactions defined!", MessageType.Info);
                            }
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("An Inventory Manager is required.", MessageType.Warning);
                        }
                        break;
                    }
                }

                changeType = (ChangeType)EditorGUILayout.EnumPopup("Change to make:", changeType);
            }
            else
            {
                EditorGUILayout.HelpBox("A Settings Manager is required for this Action.", MessageType.Warning);
            }

            AfterRunningOption();
        }
        public BuilderInspector(BuilderPaneWindow paneWindow, BuilderSelection selection, HighlightOverlayPainter highlightOverlayPainter = null)
        {
            m_HighlightOverlayPainter = highlightOverlayPainter;

            // Yes, we give ourselves a view data key. Don't do this at home!
            viewDataKey = "unity-ui-builder-inspector";

            // Init External References
            m_Selection  = selection;
            m_PaneWindow = paneWindow;

            // Load Template
            var template = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(
                BuilderConstants.UIBuilderPackagePath + "/Inspector/BuilderInspector.uxml");

            template.CloneTree(this);

            // Get the scroll view.
            // HACK: ScrollView is not capable of remembering a scroll position for content that changes often.
            // The main issue is that we expand/collapse/display/hide different parts of the Inspector
            // all the time so initially the ScrollView is empty and it restores the scroll position to zero.
            m_ScrollView = this.Q <ScrollView>("inspector-scroll-view");
            m_ScrollView.contentContainer.RegisterCallback <GeometryChangedEvent>(OnScrollViewContentGeometryChange);
            m_ScrollView.verticalScroller.valueChanged += (newValue) =>
            {
                CacheScrollPosition(newValue, m_ScrollView.verticalScroller.highValue);
                SaveViewData();
            };

            // Load styles.
            AddToClassList(s_UssClassName);
            styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.InspectorUssPathNoExt + ".uss"));
            if (EditorGUIUtility.isProSkin)
            {
                styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.InspectorUssPathNoExt + "Dark.uss"));
            }
            else
            {
                styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.InspectorUssPathNoExt + "Light.uss"));
            }

            // Matching Selectors
            m_MatchingSelectors = new BuilderInspectorMatchingSelectors(this);

            // Style Fields
            m_StyleFields = new BuilderInspectorStyleFields(this);

            // Sections
            m_Sections = new List <VisualElement>();

            // Header Section
            m_HeaderSection = new BuilderInspectorHeader(this);
            m_Sections.Add(m_HeaderSection.header);

            // Nothing Selected Section
            m_NothingSelectedSection = this.Q <Label>("nothing-selected-label");
            m_Sections.Add(m_NothingSelectedSection);

            // Multi-Selection Section
            m_MultiSelectionSection = this.Q("multi-selection-unsupported-message");
            m_MultiSelectionSection.Add(new IMGUIContainer(
                                            () => EditorGUILayout.HelpBox(BuilderConstants.MultiSelectionNotSupportedMessage, MessageType.Info, true)));
            m_Sections.Add(m_MultiSelectionSection);

            // Canvas Section
            m_CanvasSection = new BuilderInspectorCanvas(this);
            m_Sections.Add(m_CanvasSection.root);

            // StyleSheet Section
            m_StyleSheetSection = new BuilderInspectorStyleSheet(this);
            m_Sections.Add(m_StyleSheetSection.root);

            // Attributes Section
            m_AttributesSection = new BuilderInspectorAttributes(this);
            m_Sections.Add(m_AttributesSection.root);

            // Inherited Styles Section
            m_InheritedStyleSection = new BuilderInspectorInheritedStyles(this, m_MatchingSelectors);
            m_Sections.Add(m_InheritedStyleSection.root);

            // Local Styles Section
            m_LocalStylesSection = new BuilderInspectorLocalStyles(this, m_StyleFields);
            m_Sections.Add(m_LocalStylesSection.root);

            // This will take into account the current selection and then call RefreshUI().
            SelectionChanged();

            // Forward focus to the panel header.
            this.Query().Where(e => e.focusable).ForEach((e) => AddFocusable(e));
        }
        protected void drawFeatureData(LeapGraphicGroup sharedGroup)
        {
            using (new ProfilerSample("Draw Leap Gui Graphic Editor")) {
                if (targets.Length == 0)
                {
                    return;
                }
                var mainGraphic = targets[0];

                if (mainGraphic.featureData.Count == 0)
                {
                    return;
                }

                if (mainGraphic.attachedGroup != null)
                {
                    SpriteAtlasUtil.ShowInvalidSpriteWarning(mainGraphic.attachedGroup.features);
                }

                int maxGraphics = LeapGraphicPreferences.graphicMax;
                if (targets.Query().Any(e => e.attachedGroup != null && e.attachedGroup.graphics.IndexOf(e) >= maxGraphics))
                {
                    string noun         = targets.Length == 1 ? "This graphic" : "Some of these graphics";
                    string rendererName = targets.Length == 1 ? "its renderer" : "their renderers";
                    EditorGUILayout.HelpBox(noun + " may not be properly displayed because there are too many graphics on " + rendererName + ".  " +
                                            "Either lower the number of graphics or increase the maximum graphic count by visiting " +
                                            "Edit->Preferences.", MessageType.Warning);
                }

                //If we are not all attached to the same group we cannot show features
                if (!targets.Query().Select(g => g.attachedGroup).AllEqual())
                {
                    return;
                }

                EditorGUILayout.Space();

                using (new GUILayout.HorizontalScope()) {
                    EditorGUILayout.LabelField("Feature Data: ", EditorStyles.boldLabel);

                    if (sharedGroup != null)
                    {
                        var meshRendering = sharedGroup.renderingMethod as LeapMesherBase;
                        if (meshRendering != null && meshRendering.IsAtlasDirty && !EditorApplication.isPlaying)
                        {
                            if (GUILayout.Button("Refresh Atlas", GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight)))
                            {
                                meshRendering.RebuildAtlas(new ProgressBar());
                                sharedGroup.renderer.editor.ScheduleRebuild();
                            }
                        }
                    }
                }

                for (int i = 0; i < _featureTable.arraySize; i++)
                {
                    var idIndex  = _featureTable.GetArrayElementAtIndex(i);
                    var dataProp = MultiTypedListUtil.GetReferenceProperty(_featureList, idIndex);
                    EditorGUILayout.LabelField(LeapGraphicTagAttribute.GetTagName(dataProp.type));

                    if (mainGraphic.attachedGroup != null)
                    {
                        currentFeature = mainGraphic.attachedGroup.features[i];
                    }

                    EditorGUI.indentLevel++;

                    EditorGUILayout.PropertyField(dataProp, includeChildren: true);

                    EditorGUI.indentLevel--;

                    currentFeature = null;
                }

                serializedObject.ApplyModifiedProperties();
            }
        }
Exemplo n.º 9
0
        private void drawAttachmentPointsEditor(SerializedProperty property)
        {
            // Set up the draw rect space based on the image and available editor space.

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Attachment Transforms", EditorStyles.boldLabel);

            // Determine whether the target object is a prefab. AttachmentPoints cannot be edited on prefabs.
            var isTargetPrefab = Utils.IsObjectPartOfPrefabAsset(target.gameObject);

            if (isTargetPrefab)
            {
                EditorGUILayout.HelpBox("Drag the prefab into the scene to make changes to attachment points.", MessageType.Info, true);
            }

            _handTexRect = EditorGUILayout.BeginVertical(GUILayout.MinWidth(EditorGUIUtility.currentViewWidth),
                                                         GUILayout.MinHeight(EditorGUIUtility.currentViewWidth * (_handTex.height / (float)_handTex.width)),
                                                         GUILayout.MaxWidth(_handTex.width),
                                                         GUILayout.MaxHeight(_handTex.height));

            Rect imageContainerRect = _handTexRect; imageContainerRect.width = EditorGUIUtility.currentViewWidth - 30F;

            EditorGUI.DrawRect(imageContainerRect, new Color(0.2F, 0.2F, 0.2F));
            imageContainerRect.x += 1; imageContainerRect.y += 1; imageContainerRect.width -= 2; imageContainerRect.height -= 2;
            EditorGUI.DrawRect(imageContainerRect, new Color(0.6F, 0.6F, 0.6F));
            imageContainerRect.x += 1; imageContainerRect.y += 1; imageContainerRect.width -= 2; imageContainerRect.height -= 2;
            EditorGUI.DrawRect(imageContainerRect, new Color(0.2F, 0.2F, 0.2F));

            _handTexRect = new Rect(_handTexRect.x + (imageContainerRect.center.x - _handTexRect.center.x),
                                    _handTexRect.y,
                                    _handTexRect.width,
                                    _handTexRect.height);
            EditorGUI.DrawTextureTransparent(_handTexRect, _handTex);
            EditorGUILayout.Space();


            // Draw the toggles for the attachment points.

            EditorGUI.BeginDisabledGroup(isTargetPrefab);

            makeAttachmentPointsToggle("Palm", new Vector2(0.100F, 0.160F));
            makeAttachmentPointsToggle("Wrist", new Vector2(0.080F, 0.430F));

            makeAttachmentPointsToggle("ThumbProximalJoint", new Vector2(-0.190F, 0.260F));
            makeAttachmentPointsToggle("ThumbDistalJoint", new Vector2(-0.310F, 0.170F));
            makeAttachmentPointsToggle("ThumbTip", new Vector2(-0.390F, 0.110F));

            makeAttachmentPointsToggle("IndexKnuckle", new Vector2(-0.040F, -0.040F));
            makeAttachmentPointsToggle("IndexMiddleJoint", new Vector2(-0.060F, -0.170F));
            makeAttachmentPointsToggle("IndexDistalJoint", new Vector2(-0.075F, -0.280F));
            makeAttachmentPointsToggle("IndexTip", new Vector2(-0.080F, -0.380F));

            makeAttachmentPointsToggle("MiddleKnuckle", new Vector2(0.080F, -0.050F));
            makeAttachmentPointsToggle("MiddleMiddleJoint", new Vector2(0.080F, -0.190F));
            makeAttachmentPointsToggle("MiddleDistalJoint", new Vector2(0.080F, -0.310F));
            makeAttachmentPointsToggle("MiddleTip", new Vector2(0.090F, -0.420F));

            makeAttachmentPointsToggle("RingKnuckle", new Vector2(0.195F, -0.020F));
            makeAttachmentPointsToggle("RingMiddleJoint", new Vector2(0.220F, -0.150F));
            makeAttachmentPointsToggle("RingDistalJoint", new Vector2(0.230F, -0.270F));
            makeAttachmentPointsToggle("RingTip", new Vector2(0.245F, -0.380F));

            makeAttachmentPointsToggle("PinkyKnuckle", new Vector2(0.295F, 0.040F));
            makeAttachmentPointsToggle("PinkyMiddleJoint", new Vector2(0.340F, -0.050F));
            makeAttachmentPointsToggle("PinkyDistalJoint", new Vector2(0.380F, -0.130F));
            makeAttachmentPointsToggle("PinkyTip", new Vector2(0.410F, -0.210F));

            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndVertical();
        }
Exemplo n.º 10
0
        public override void OnInspectorGUI()
        {
            var proCamera2DPixelPerfectSprite = (ProCamera2DPixelPerfectSprite)target;

            if (proCamera2DPixelPerfectSprite.ProCamera2D == null)
            {
                EditorGUILayout.HelpBox("ProCamera2D is not set.", MessageType.Error, true);
                return;
            }

            // No sprite found
            var hasSprite = false;

#if PC2D_TK2D_SUPPORT
            if (proCamera2DPixelPerfectSprite.GetComponent <tk2dBaseSprite>() != null)
            {
                hasSprite = true;
            }
            else
            {
#endif
            if (proCamera2DPixelPerfectSprite.GetComponent <SpriteRenderer>() != null)
            {
                hasSprite = true;
            }
#if PC2D_TK2D_SUPPORT
        }
#endif

            // if (!hasSprite)
            //     EditorGUILayout.HelpBox("This component needs a Sprite renderer on the same GameObject!", MessageType.Error, true);


            // Rigidbody, collider, character controller warning
            if (proCamera2DPixelPerfectSprite.IsAMovingObject &&
                (proCamera2DPixelPerfectSprite.GetComponent <Rigidbody>() != null ||
                 proCamera2DPixelPerfectSprite.GetComponent <Rigidbody2D>() != null ||
                 proCamera2DPixelPerfectSprite.GetComponent <Collider>() != null ||
                 proCamera2DPixelPerfectSprite.GetComponent <Collider2D>() != null ||
                 proCamera2DPixelPerfectSprite.GetComponent <CharacterController>() != null))
            {
                EditorGUILayout.HelpBox("You should not add this component to GameObjects that have physics components, because rounding the sprite to a pixel-perfect position might interfere with the physics calculations. Please add the sprite as a child of this GameObject and add this component to it instead.", MessageType.Warning, true);
            }

            serializedObject.Update();

            // Show script link
            _script = EditorGUILayout.ObjectField("Script", _script, typeof(MonoScript), false) as MonoScript;

            // ProCamera2D
            _tooltip = new GUIContent("Pro Camera 2D", "");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_pc2D"), _tooltip);

            // Moving object
            _tooltip = new GUIContent("Is A Moving Object", "If checked, the object position will be aligned to pixel perfect every frame. To improve performance, enable only if the object (or its parent) move.");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("IsAMovingObject"), _tooltip);

            // Child sprite
            if (proCamera2DPixelPerfectSprite.IsAMovingObject && proCamera2DPixelPerfectSprite.transform.parent != null)
            {
                _tooltip = new GUIContent("Use Parent Movement", "Enable if you're moving the parent of this sprite instead of the sprite itself.");
                EditorGUILayout.PropertyField(serializedObject.FindProperty("IsAChildSprite"), _tooltip);
            }
            else
            {
                proCamera2DPixelPerfectSprite.IsAChildSprite = false;
            }

            // Local Position
            if (proCamera2DPixelPerfectSprite.IsAChildSprite)
            {
                EditorGUILayout.BeginHorizontal();

                _tooltip = new GUIContent("Local Position", "If you're using the parent movement, you have to set this sprite local position using this value.");
                EditorGUILayout.PropertyField(serializedObject.FindProperty("LocalPosition"), _tooltip);

                if (GUILayout.Button("R", GUILayout.Width(20)))
                {
                    serializedObject.FindProperty("LocalPosition").vector2Value = Vector2.zero;
                }

                EditorGUILayout.EndHorizontal();
            }

            // Pixels Per Unit
            _tooltip = new GUIContent("Pixels Per Unit", "Pixels Per Unit");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("pixelsPerUnit"), _tooltip);

            // Pixel Scale
            _tooltip = new GUIContent("Sprite Scale", "The scale of this sprite");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("SpriteScale"), _tooltip);

            // Scale 0 warning
            if (proCamera2DPixelPerfectSprite.SpriteScale == 0)
            {
                EditorGUILayout.HelpBox("A scale of 0 allows you to manually scale the sprite, however, it doesn't guarantee that it will be pixel-perfect. Use a scale different than 0 to guarantee your sprite size is pixel-perfect.", MessageType.Warning, true);
            }

            // Save properties
            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 11
0
    public override void OnInspectorGUI()
    {
        BetterWaypointFollower script = (BetterWaypointFollower)target;

        script.circuitObject = EditorGUILayout.ObjectField("Waypoint Circuit", script.circuitObject, typeof(WaypointCircuit), true);
        if (script.circuitObject != null)
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("-- Settings --", EditorStyles.boldLabel);
            script.circuit           = (WaypointCircuit)script.circuitObject;
            script.routeSpeed        = EditorGUILayout.FloatField("Speed In Units/Sec", script.routeSpeed);
            script.lookAheadDistance = EditorGUILayout.FloatField("Look Ahead Distance", script.lookAheadDistance);
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("-- Varying Speed --", EditorStyles.boldLabel);
            if (GUILayout.Toggle(script.varyingSpeed, " Enable Varying Circuit Speeds?"))
            {
                script.varyingSpeed = true;
                script.InitializeSpeeds();
            }
            else
            {
                script.varyingSpeed = false;
            }
            if (script.varyingSpeed)
            {
                EditorGUILayout.Space();
                script.initialSpeed = EditorGUILayout.FloatField("Initial Speed In Units/Sec", script.initialSpeed);
                EditorGUILayout.Space();
                for (int i = 0; i < script.waypointSpeedFactors.Length; i++)
                {
                    script.waypointSpeedFactors[i] = EditorGUILayout.Slider("Waypoint " + i.ToString("D3") + " Factor", script.waypointSpeedFactors[i], 0f, 2f);
                }
                EditorGUILayout.Space();
                script.rateOfChange = EditorGUILayout.Slider("Rate Of Change Factor", script.rateOfChange, 0f, 2f);
                EditorGUILayout.HelpBox("Waypoint speed factors take effect as soon as you pass that point, "
                                        + "and how quickly the change happens is determined by the 'Rate Of Change'."
                                        + "\nThe speed factor is exponential. For example, 30 to the power of 2 is 900.", MessageType.Info);
            }
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("-- Invoke Methods --", EditorStyles.boldLabel);
            if (GUILayout.Toggle(script.invokeMethods, " Enable Invoke Method Calls At Waypoints?"))
            {
                script.invokeMethods = true;
                script.InitializeInvoke();
            }
            else
            {
                script.invokeMethods = false;
            }
            if (script.invokeMethods)
            {
                EditorGUILayout.Space();
                for (int i = 0; i < script.invokeWaypointEnabled.Length; i++)
                {
                    script.invokeWaypointEnabled[i] = EditorGUILayout.Toggle("Invoke At Waypoint " + i.ToString("D3") + "?", script.invokeWaypointEnabled[i]);
                    if (script.invokeWaypointEnabled[i])
                    {
                        script.invokeObject[i] = EditorGUILayout.ObjectField("Game Object Target", script.invokeObject[i], typeof(MonoBehaviour), true);
                        if (script.invokeObject[i] != null)
                        {
                            Type         type    = script.invokeObject[i].GetType();
                            MethodInfo[] methods = type.GetMethods();
                            if (monoBehaviours == null)
                            {
                                FillList();
                            }
                            string[] names = new string[methods.Length - totalMethods + 1];
                            if (names.Length == 0)
                            {
                                EditorGUILayout.HelpBox("You have no public methods in your game object."
                                                        + "\nAdd 'public' in front of the method you wish to invoke.", MessageType.Error);
                            }
                            else
                            {
                                int l = 0;
                                for (int j = 0; j < methods.Length; j++)
                                {
                                    if (!monoBehaviours.Contains(methods[j].Name))
                                    {
                                        names[l++] = methods[j].Name;
                                    }
                                }
                                int index = 0;
                                for (int j = 0; j < names.Length; j++)
                                {
                                    if (names[j] == script.invokeNames[i])
                                    {
                                        index = j;
                                        break;
                                    }
                                }
                                index = EditorGUILayout.Popup("Method To Call", index, names);
                                script.invokeNames[i] = names[index];
                                float delay = EditorGUILayout.FloatField("Delay In Seconds", script.invokeDelay[i]);
                                script.invokeDelay[i] = delay < 0f ? 0f : delay;
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 12
0
        public override void CharSettingsGUI()
        {
                        #if UNITY_EDITOR
            CustomGUILayout.BeginVertical();
            EditorGUILayout.LabelField("Standard 2D animations:", EditorStyles.boldLabel);

            character.talkingAnimation = (TalkingAnimation)CustomGUILayout.EnumPopup("Talk animation style:", character.talkingAnimation, "", "How talking animations are handled");
            character.spriteChild      = (Transform)CustomGUILayout.ObjectField <Transform> ("Sprite child:", character.spriteChild, true, "", "The sprite Transform, which should be a child GameObject");

            if (character.spriteChild && character.spriteChild.GetComponent <Animator>() == null)
            {
                character.customAnimator = (Animator)CustomGUILayout.ObjectField <Animator> ("Animator (if not on s.c.):", character.customAnimator, true, "", "The Animator component, which will be assigned automatically if not set manually.");
            }

            character.idleAnimSprite = CustomGUILayout.TextField("Idle name:", character.idleAnimSprite, "", "The name of the 'Idle' animation(s), without suffix");
            character.walkAnimSprite = CustomGUILayout.TextField("Walk name:", character.walkAnimSprite, "", "The name of the 'Walk' animation(s), without suffix");
            character.runAnimSprite  = CustomGUILayout.TextField("Run name:", character.runAnimSprite, "", "The name of the 'Run' animation(s), without suffix");
            if (character.talkingAnimation == TalkingAnimation.Standard)
            {
                character.talkAnimSprite       = CustomGUILayout.TextField("Talk name:", character.talkAnimSprite, "", "The name of the 'Talk' animation(s), without suffix");
                character.separateTalkingLayer = CustomGUILayout.Toggle("Head on separate layer?", character.separateTalkingLayer, "", "If True, the head animation will be handled on a non-root layer when talking");
                if (character.separateTalkingLayer)
                {
                    character.headLayer = CustomGUILayout.IntField("Head layer:", character.headLayer, "", "The Animator layer used to play head animations while talking");
                    if (character.headLayer < 1)
                    {
                        EditorGUILayout.HelpBox("The head layer index must be 1 or greater.", MessageType.Warning);
                    }
                }
            }

            character.spriteDirectionData.ShowGUI();
            character.angleSnapping = AngleSnapping.None;

            if (character.spriteDirectionData.HasDirections())
            {
                character.frameFlipping = (AC_2DFrameFlipping)CustomGUILayout.EnumPopup("Frame flipping:", character.frameFlipping, "", "The type of frame-flipping to use");
                if (character.frameFlipping != AC_2DFrameFlipping.None)
                {
                    character.flipCustomAnims = CustomGUILayout.Toggle("Flip custom animations?", character.flipCustomAnims, "", "If True, then custom animations will also be flipped");
                }
            }

            character.crossfadeAnims = CustomGUILayout.Toggle("Crossfade animation?", character.crossfadeAnims, "", "If True, characters will crossfade between standard animations");

            Animator charAnimator = character.GetAnimator();
            if (charAnimator == null || !charAnimator.applyRootMotion)
            {
                character.antiGlideMode = CustomGUILayout.ToggleLeft("Only move when sprite changes?", character.antiGlideMode, "", "If True, then sprite-based characters will only move when their sprite frame changes");

                if (character.antiGlideMode)
                {
                    if (character.GetComponent <Rigidbody2D>())
                    {
                        EditorGUILayout.HelpBox("This feature will disable use of the Rigidbody2D component.", MessageType.Warning);
                    }
                    if (character.IsPlayer && AdvGame.GetReferences() != null && AdvGame.GetReferences().settingsManager)
                    {
                        if (AdvGame.GetReferences().settingsManager.movementMethod != MovementMethod.PointAndClick && AdvGame.GetReferences().settingsManager.movementMethod != MovementMethod.None)
                        {
                            EditorGUILayout.HelpBox("This feature will not work with collision - it is not recommended for " + AdvGame.GetReferences().settingsManager.movementMethod.ToString() + " movement.", MessageType.Warning);
                        }
                    }
                }
            }

            if (SceneSettings.CameraPerspective != CameraPerspective.TwoD)
            {
                character.rotateSprite3D = (RotateSprite3D)CustomGUILayout.EnumPopup("Rotate sprite to:", character.rotateSprite3D, "", "The method by which the character should face the camera");
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(" ", GUILayout.Width(9));
            listExpectedAnimations = EditorGUILayout.Foldout(listExpectedAnimations, "List expected animations?");
            EditorGUILayout.EndHorizontal();
            if (listExpectedAnimations)
            {
                string result = "\n";
                result = ShowExpected(character, character.idleAnimSprite, result, 0);
                result = ShowExpected(character, character.walkAnimSprite, result, 0);
                result = ShowExpected(character, character.runAnimSprite, result, 0);
                if (character.talkingAnimation == TalkingAnimation.Standard)
                {
                    if (character.separateTalkingLayer)
                    {
                        result  = ShowExpected(character, character.idleAnimSprite, result, character.headLayer);
                        result  = ShowExpected(character, character.talkAnimSprite, result, character.headLayer);
                        result += "\n- " + hideHeadClip + "  (" + character.headLayer + ")";
                    }
                    else
                    {
                        result = ShowExpected(character, character.talkAnimSprite, result, 0);
                    }
                }

                EditorGUILayout.HelpBox("The following animations are required, based on the settings above (numbers are the Animator layer indices):" + result, MessageType.Info);
            }

            CustomGUILayout.EndVertical();

            if (GUI.changed && character)
            {
                EditorUtility.SetDirty(character);
            }
                        #endif
        }
Exemplo n.º 13
0
        public override void ActionCharAnimGUI(ActionCharAnim action, List <ActionParameter> parameters = null)
        {
                        #if UNITY_EDITOR
            action.method = (ActionCharAnim.AnimMethodChar)EditorGUILayout.EnumPopup("Method:", action.method);

            if (action.method == ActionCharAnim.AnimMethodChar.PlayCustom)
            {
                action.clip2DParameterID = Action.ChooseParameterGUI("Clip:", parameters, action.clip2DParameterID, ParameterType.String);
                if (action.clip2DParameterID < 0)
                {
                    action.clip2D = EditorGUILayout.TextField("Clip:", action.clip2D);
                }

                action.includeDirection = EditorGUILayout.Toggle("Add directional suffix?", action.includeDirection);

                if (action.animChar && action.animChar.talkingAnimation == TalkingAnimation.Standard && action.animChar.separateTalkingLayer)
                {
                    action.hideHead = EditorGUILayout.Toggle("Hide head?", action.hideHead);
                    if (action.hideHead)
                    {
                        EditorGUILayout.HelpBox("The head layer will play '" + hideHeadClip + "' for the duration.", MessageType.Info);
                    }
                }

                action.layerInt = EditorGUILayout.IntField("Mecanim layer:", action.layerInt);
                action.fadeTime = EditorGUILayout.Slider("Transition time:", action.fadeTime, 0f, 1f);
                action.willWait = EditorGUILayout.Toggle("Wait until finish?", action.willWait);
                if (action.willWait)
                {
                    action.idleAfter = EditorGUILayout.Toggle("Return to idle after?", action.idleAfter);
                }
            }
            else if (action.method == ActionCharAnim.AnimMethodChar.StopCustom)
            {
                EditorGUILayout.HelpBox("This Action does not work for Sprite-based characters.", MessageType.Info);
            }
            else if (action.method == ActionCharAnim.AnimMethodChar.SetStandard)
            {
                action.standard = (AnimStandard)EditorGUILayout.EnumPopup("Change:", action.standard);

                action.clip2DParameterID = Action.ChooseParameterGUI("Clip:", parameters, action.clip2DParameterID, ParameterType.String);
                if (action.clip2DParameterID < 0)
                {
                    action.clip2D = EditorGUILayout.TextField("Clip:", action.clip2D);
                }

                if (action.standard == AnimStandard.Walk || action.standard == AnimStandard.Run)
                {
                    action.changeSound = EditorGUILayout.Toggle("Change sound?", action.changeSound);
                    if (action.changeSound)
                    {
                        action.newSoundParameterID = Action.ChooseParameterGUI("New sound:", parameters, action.newSoundParameterID, ParameterType.UnityObject);
                        if (action.newSoundParameterID < 0)
                        {
                            action.newSound = (AudioClip)EditorGUILayout.ObjectField("New sound:", action.newSound, typeof(AudioClip), false);
                        }
                    }
                    action.changeSpeed = EditorGUILayout.Toggle("Change speed?", action.changeSpeed);
                    if (action.changeSpeed)
                    {
                        action.newSpeedParameterID = Action.ChooseParameterGUI("New speed:", parameters, action.newSpeedParameterID, ParameterType.Float);
                        if (action.newSpeedParameterID < 0)
                        {
                            action.newSpeed = EditorGUILayout.FloatField("New speed:", action.newSpeed);
                        }
                    }
                }
            }
            else if (action.method == ActionCharAnim.AnimMethodChar.ResetToIdle)
            {
                action.idleAfterCustom = EditorGUILayout.Toggle("Wait for animation to finish?", action.idleAfterCustom);
            }

            if (GUI.changed && action != null)
            {
                EditorUtility.SetDirty(action);
            }
                        #endif
        }
Exemplo n.º 14
0
        /// <summary>
        /// Custom editor for fields representing the distance ranges by which we calculate expressions
        /// </summary>
        /// <param name="reverseStatesProperty">The reverse states property</param>
        /// <param name="minimumsProperty">The maximum distance values property</param>
        /// <param name="maximumsProperty">The minimum distance values property</param>
        public static void ExpressionDistanceRangeFields(SerializedProperty reverseStatesProperty,
                                                         SerializedProperty minimumsProperty, SerializedProperty maximumsProperty)
        {
            if (!minimumsProperty.isArray && !maximumsProperty.isArray)
            {
                EditorGUILayout.HelpBox("The min and max properties must be arrays", MessageType.Error);
                return;
            }

            const float minimumRange    = 0.001f;
            const float minimumDistance = 0.001f;
            const float maximumDistance = 0.1f;

            EditorGUILayout.LabelField("Facial Expression Landmark Distance Ranges", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox("These ranges describe distances between landmarks. We use these distances to calculate expressions.\n" +
                                    "At minimum distance, coefficient is 0.  At maximum distance, coefficient is 1.\n" +
                                    "Some expressions (like eye close) have a smaller max, which means they work on inverse distance", MessageType.Info);

            for (var i = 0; i < minimumsProperty.arraySize; ++i)
            {
                var minElement          = minimumsProperty.GetArrayElementAtIndex(i);
                var maxElement          = maximumsProperty.GetArrayElementAtIndex(i);
                var reverseStateElement = reverseStatesProperty.GetArrayElementAtIndex(i);

                var label = ((MRFaceExpression)i).ToString();
                EditorGUILayout.LabelField(label, EditorStyles.boldLabel);

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var reverse = EditorGUILayout.Toggle("Reverse", reverseStateElement.boolValue);

                    float min;
                    float max;
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        min = EditorGUILayout.DelayedFloatField("Minimum", minElement.floatValue);
                        max = EditorGUILayout.DelayedFloatField("Maximum", maxElement.floatValue);
                    }

                    if (reverse)
                    {
                        EditorGUILayout.MinMaxSlider("Range", ref max, ref min, minimumDistance, maximumDistance);
                    }
                    else
                    {
                        EditorGUILayout.MinMaxSlider("Range", ref min, ref max, minimumDistance, maximumDistance);
                    }

                    if (check.changed)
                    {
                        var range = Mathf.Abs(max - min);
                        if (range < minimumRange)
                        {
                            Debug.LogWarningFormat("{0} has a range of {1}, below the minimum of {2}", label, range.ToString("F4"), minimumRange);
                            continue;
                        }

                        reverseStateElement.boolValue = reverse;
                        if (reverse ? max < min : min < max)
                        {
                            minElement.floatValue = Mathf.Clamp01(min);
                            maxElement.floatValue = Mathf.Clamp01(max);
                        }
                    }
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Implement this function to make a custom inspector.
        /// </summary>
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(_spParticleSystem);
            EditorGUI.indentLevel++;
            var ps = _spParticleSystem.objectReferenceValue as ParticleSystem;

            if (ps)
            {
                var pr = ps.GetComponent <ParticleSystemRenderer> ();
                var sp = new SerializedObject(pr).FindProperty("m_Materials");

                EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(0), s_ContentParticleMaterial);
                EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(1), s_ContentTrailMaterial);
                sp.serializedObject.ApplyModifiedProperties();

                if (!Application.isPlaying && pr.enabled)
                {
                    EditorGUILayout.HelpBox("ParticleSystemRenderer will be disable on playing.", MessageType.Info);
                }
            }
            EditorGUI.indentLevel--;

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(_spTrailParticle);
            EditorGUI.EndDisabledGroup();

            var current = target as UIParticle;

            EditorGUILayout.PropertyField(_spIgnoreParent);

            EditorGUI.BeginDisabledGroup(!current.isRoot);
            EditorGUILayout.PropertyField(_spScale);
            EditorGUI.EndDisabledGroup();

            // AnimatableProperties
            AnimatedPropertiesEditor.DrawAnimatableProperties(_spAnimatableProperties, current.material);

            current.GetComponentsInChildren <ParticleSystem> (true, s_ParticleSystems);
            if (s_ParticleSystems.Any(x => x.GetComponent <UIParticle> () == null))
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.HelpBox("There are child ParticleSystems that does not have a UIParticle component.\nAdd UIParticle component to them.", MessageType.Warning);
                GUILayout.BeginVertical();
                if (GUILayout.Button("Fix"))
                {
                    foreach (var p in s_ParticleSystems.Where(x => !x.GetComponent <UIParticle> ()))
                    {
                        p.gameObject.AddComponent <UIParticle> ();
                    }
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
            s_ParticleSystems.Clear();

            if (current.maskable && current.material && current.material.shader)
            {
                var mat    = current.material;
                var shader = mat.shader;
                foreach (var propName in s_MaskablePropertyNames)
                {
                    if (!mat.HasProperty(propName))
                    {
                        EditorGUILayout.HelpBox(string.Format("Shader {0} doesn't have '{1}' property. This graphic is not maskable.", shader.name, propName), MessageType.Warning);
                        break;
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 16
0
    public override void OnInspectorGUI()
    {
        UICamera cam = target as UICamera;

        GUILayout.Space(3f);

        serializedObject.Update();

        if (UICamera.eventHandler != cam)
        {
            EditorGUILayout.PropertyField(serializedObject.FindProperty("eventType"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("eventReceiverMask"), new GUIContent("Event Mask"));
            serializedObject.ApplyModifiedProperties();

            EditorGUILayout.HelpBox("All other settings are inherited from the First Camera.", MessageType.Info);

            if (GUILayout.Button("Select the First Camera"))
            {
                Selection.activeGameObject = UICamera.eventHandler.gameObject;
            }
        }
        else
        {
            SerializedProperty mouse      = serializedObject.FindProperty("useMouse");
            SerializedProperty touch      = serializedObject.FindProperty("useTouch");
            SerializedProperty keyboard   = serializedObject.FindProperty("useKeyboard");
            SerializedProperty controller = serializedObject.FindProperty("useController");

            EditorGUILayout.PropertyField(serializedObject.FindProperty("eventType"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("eventReceiverMask"), new GUIContent("Event Mask"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("debug"));

            EditorGUI.BeginDisabledGroup(!mouse.boolValue && !touch.boolValue);
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("allowMultiTouch"));
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(!mouse.boolValue);
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("stickyTooltip"));

                GUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(serializedObject.FindProperty("tooltipDelay"));
                GUILayout.Label("seconds", GUILayout.MinWidth(60f));
                GUILayout.EndHorizontal();
            }
            EditorGUI.EndDisabledGroup();

            GUILayout.BeginHorizontal();
            SerializedProperty rd = serializedObject.FindProperty("rangeDistance");
            EditorGUILayout.PropertyField(rd, new GUIContent("Raycast Range"));
            GUILayout.Label(rd.floatValue < 0f ? "unlimited" : "units", GUILayout.MinWidth(60f));
            GUILayout.EndHorizontal();

            NGUIEditorTools.SetLabelWidth(80f);

            if (NGUIEditorTools.DrawHeader("Event Sources"))
            {
                NGUIEditorTools.BeginContents();
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(mouse, new GUIContent("Mouse"), GUILayout.MinWidth(100f));
                    EditorGUILayout.PropertyField(touch, new GUIContent("Touch"), GUILayout.MinWidth(100f));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(keyboard, new GUIContent("Keyboard"), GUILayout.MinWidth(100f));
                    EditorGUILayout.PropertyField(controller, new GUIContent("Controller"), GUILayout.MinWidth(100f));
                    GUILayout.EndHorizontal();
                }
                NGUIEditorTools.EndContents();
            }

            if ((mouse.boolValue || touch.boolValue) && NGUIEditorTools.DrawHeader("Thresholds"))
            {
                NGUIEditorTools.BeginContents();
                {
                    EditorGUI.BeginDisabledGroup(!mouse.boolValue);
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("mouseDragThreshold"), new GUIContent("Mouse Drag"), GUILayout.Width(120f));
                    GUILayout.Label("pixels");
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("mouseClickThreshold"), new GUIContent("Mouse Click"), GUILayout.Width(120f));
                    GUILayout.Label("pixels");
                    GUILayout.EndHorizontal();
                    EditorGUI.EndDisabledGroup();

                    EditorGUI.BeginDisabledGroup(!touch.boolValue);
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("touchDragThreshold"), new GUIContent("Touch Drag"), GUILayout.Width(120f));
                    GUILayout.Label("pixels");
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("touchClickThreshold"), new GUIContent("Touch Tap"), GUILayout.Width(120f));
                    GUILayout.Label("pixels");
                    GUILayout.EndHorizontal();
                    EditorGUI.EndDisabledGroup();
                }
                NGUIEditorTools.EndContents();
            }

            if ((mouse.boolValue || keyboard.boolValue || controller.boolValue) && NGUIEditorTools.DrawHeader("Axes and Keys"))
            {
                NGUIEditorTools.BeginContents();
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("horizontalAxisName"), new GUIContent("Horizontal"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("verticalAxisName"), new GUIContent("Vertical"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("scrollAxisName"), new GUIContent("Scroll"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("submitKey0"), new GUIContent("Submit 1"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("submitKey1"), new GUIContent("Submit 2"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("cancelKey0"), new GUIContent("Cancel 1"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("cancelKey1"), new GUIContent("Cancel 2"));
                }
                NGUIEditorTools.EndContents();
            }
            serializedObject.ApplyModifiedProperties();
        }
    }
        public void DrawBaking()
        {
            if (!graph.animationLoaded)
            {
                return;
            }
            if (graph.rendererData == null)
            {
                graph.rendererData      = ScriptableObject.CreateInstance <RendererData>();
                graph.rendererData.name = "RendererData";
                AssetDatabase.AddObjectToAsset(graph.rendererData, graph);
                graph.IsDirty = true;
            }
            GUILayout.Space(4);
            var horizontalRect   = EditorGUILayout.BeginHorizontal();
            var changeButtonRect = horizontalRect;

            changeButtonRect.x     = horizontalRect.width - 35;
            changeButtonRect.width = 50;
            if (GUI.Button(changeButtonRect, "Change", EditorStyles.miniButton))
            {
                var path = EditorUtility.OpenFolderPanel("Choose Output Path", outputPath, "");
                if (!string.IsNullOrEmpty(path))
                {
                    outputPath = path;
                }
            }
            EditorGUILayout.LabelField("Output: " + StringUtils.ClampPath(outputPath, horizontalRect.width - 110));

            EditorGUILayout.EndHorizontal();
            GUILayout.Space(4);

            if (string.IsNullOrEmpty(outputPath))
            {
                return;
            }
            if (!Directory.Exists(outputPath))
            {
                return;
            }

            if (meshRenderer == null)
            {
                EditorGUILayout.HelpBox("A SkinnedMeshRenderer Component was not found on the GameObject's children ", MessageType.Error);
                GUILayout.Space(8);
                return;
            }
            else
            {
                EditorGUILayout.HelpBox("✔ Found Skinned Mesh Renderer ", MessageType.None);
            }
            if (rootBone == null)
            {
                EditorGUILayout.HelpBox("✔ The Root Bone is not found on the GameObject's Skinned Mesh Renderer", MessageType.Error);
                GUILayout.Space(8);
                return;
            }
            else
            {
                EditorGUILayout.HelpBox("✔ Found Root Bone: " + rootBone.name, MessageType.None);
            }
            if (graph.PrefabAnimation == null)
            {
                EditorGUILayout.HelpBox("The Animation Component was not found on the GameObject's children. We need a reference to it 's animation clips in order to bake them.", MessageType.Error);
                EditorGUILayout.HelpBox("Importing your model with Legacy Animations will automatically add this component.", MessageType.Info);
                GUILayout.Space(8);
                return;
            }
            if (rootBone.rotation != Quaternion.identity)
            {
                EditorGUILayout.HelpBox("✔ Root Bone rotation will be adjusted to identity", MessageType.None);
            }
            if (rootBone.localScale != Vector3.one)
            {
                EditorGUILayout.HelpBox("✔ Root Bone scale will be adjusted to world space", MessageType.None);
            }
            if (meshRenderer.transform.rotation != Quaternion.identity)
            {
                EditorGUILayout.HelpBox("✔ Mesh rotation will be adjusted to identity", MessageType.None);
            }
            if (meshRenderer.transform.localScale != Vector3.one)
            {
                EditorGUILayout.HelpBox("✔ Mesh scale will be adjusted to world space", MessageType.None);
            }
            if (graph.meshes.Count > 0)
            {
                EditorGUILayout.HelpBox($"✔ Found {graph.meshes.Count} meshes on the bones.", MessageType.None);
            }
            EditorGUILayout.HelpBox($"✔ Position and Normal Texture Size: {TextureWidth} x {TextureHeight} ({(TextureWidth * TextureHeight / 131072f).ToString("N0")}MB)", MessageType.None);

            if (GUILayout.Button("1. Generate ECS Component"))
            {
                CreateComponent();
                AssetDatabase.Refresh();
            }
            if (GUILayout.Button("2. Bake Assets and Prefab"))
            {
                Bake(GetClips());
            }
        }
        public override void OnInspectorGUI()
        {
            RenderHeader("The Input System Profile helps developers configure input no matter what platform you're building for.");

            serializedObject.Update();
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(focusProviderType, FocusProviderContent);
            EditorGUILayout.PropertyField(gazeProviderType, GazeProviderContent);
            EditorGUILayout.PropertyField(gazeCursorPrefab);

            EditorGUILayout.Space();

            showGlobalPointerOptions = EditorGUILayoutExtensions.FoldoutWithBoldLabel(showGlobalPointerOptions, GlobalPointerSettingsContent, true);

            if (showGlobalPointerOptions)
            {
                EditorGUILayout.HelpBox("Global pointer options applied to all controllers that support pointers. You may override these globals per controller mapping profile.", MessageType.Info);
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(pointingExtent);
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(pointerRaycastLayerMasks, true);
                EditorGUILayout.Space();

                EditorGUI.BeginChangeCheck();
                EditorGUI.indentLevel--;
                var newValue = EditorGUILayout.ToggleLeft(new GUIContent(drawDebugPointingRays.displayName, drawDebugPointingRays.tooltip), drawDebugPointingRays.boolValue);
                EditorGUI.indentLevel++;

                if (EditorGUI.EndChangeCheck())
                {
                    drawDebugPointingRays.boolValue = newValue;
                }

                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(debugPointingRayColors, true);
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            showGlobalHandOptions = EditorGUILayoutExtensions.FoldoutWithBoldLabel(showGlobalHandOptions, GlobalHandSettingsContent, true);

            if (showGlobalHandOptions)
            {
                EditorGUILayout.HelpBox("Global hand tracking options applied to all platforms that support hand tracking. You may override these globals per platform in the platform's hand controller data provider profile.", MessageType.Info);
                EditorGUI.indentLevel++;
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Hand Rendering Settings", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(renderingMode);
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Hand Physics Settings", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(handPhysicsEnabled);
                EditorGUILayout.PropertyField(useTriggers);
                EditorGUILayout.PropertyField(boundsMode);
                poseProfilesList.DoLayoutList();
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(inputActionsProfile);
            EditorGUILayout.PropertyField(speechCommandsProfile);
            EditorGUILayout.PropertyField(gesturesProfile);

            EditorGUILayout.Space();

            showAggregatedSimpleControllerMappingProfiles = EditorGUILayoutExtensions.FoldoutWithBoldLabel(showAggregatedSimpleControllerMappingProfiles, ShowControllerMappingsContent);

            if (showAggregatedSimpleControllerMappingProfiles)
            {
                foreach (var controllerMappingProfile in controllerMappingProfiles)
                {
                    var(dataProviderProfile, mappingProfile) = controllerMappingProfile.Value;
                    var profileEditor = CreateEditor(dataProviderProfile);

                    if (profileEditor is BaseMixedRealityControllerDataProviderProfileInspector inspector)
                    {
                        inspector.RenderControllerMappingButton(mappingProfile);
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();

            if (EditorGUI.EndChangeCheck() &&
                MixedRealityToolkit.IsInitialized)
            {
                EditorApplication.delayCall += () => MixedRealityToolkit.Instance.ResetProfile(MixedRealityToolkit.Instance.ActiveProfile);
            }

            base.OnInspectorGUI();
        }
Exemplo n.º 19
0
        private void OnGUI()
        {
            lineHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

            GUILayoutHelper.Vertical(() =>
            {
                GUILayoutHelper.Area(new Rect(0, 0, 3 * position.width / 8, position.height), () =>
                {
                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        GUILayout.Box((Texture2D)EditorGUIUtility.Load("Assets/Resources/AppIcon1.png"), GUILayout.Width(50), GUILayout.Height(50));
                        var titleStyle      = new GUIStyle(EditorStyles.largeLabel);
                        titleStyle.font     = EditorGUIUtility.Load("Assets/Resources/Fonts/TESFonts/Kingthings Petrock.ttf") as Font;
                        titleStyle.fontSize = 50;
                        GUILayout.Label(modName, titleStyle);
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        GUILayout.Label(localPath);

                        if (IconButton("d_editicon.sml", "Select target path"))
                        {
                            if (!string.IsNullOrEmpty(targetPath = EditorUtility.OpenFolderPanel("Select mod folder", rootPath, "Mod")))
                            {
                                Load();
                            }
                        }
                        if (IconButton("d_Refresh", "Reload and discharge unsaved changes"))
                        {
                            Load();
                        }
                        using (new EditorGUI.DisabledScope(modName == "None" || duplicateSections || duplicateKeys))
                            if (IconButton("d_P4_CheckOutLocal", "Save settings to disk"))
                            {
                                Save();
                            }
                    });

                    saveOnExit = EditorGUILayout.ToggleLeft(new GUIContent("Save on Exit", "Save automatically when window is closed."), saveOnExit);

                    if (modName == "None")
                    {
                        EditorGUILayout.HelpBox("Select a folder to store settings.", MessageType.Info);
                    }
                    if (duplicateSections)
                    {
                        EditorGUILayout.HelpBox("Multiple sections with the same name detected!", MessageType.Error);
                    }
                    if (duplicateKeys)
                    {
                        EditorGUILayout.HelpBox("Multiple keys with the same name in a section detected!", MessageType.Error);
                    }

                    DrawHeader("Header");
                    EditorGUILayout.HelpBox("Version of settings checked against local values and presets.", MessageType.None);
                    data.Version = EditorGUILayout.TextField("Version", data.Version);

                    DrawHeader("Presets");
                    EditorGUILayout.HelpBox("Pre-defined values for all or a set of settings. Author is an optional field.", MessageType.None);
                    presetsScrollPosition = GUILayoutHelper.ScrollView(presetsScrollPosition, () => presets.DoLayoutList());
                    EditorGUILayout.Space();
                    if (presets.index != -1)
                    {
                        var preset    = data.Presets[presets.index];
                        preset.Author = EditorGUILayout.TextField("Author", preset.Author);
                        EditorGUILayout.PrefixLabel("Description");
                        preset.Description = EditorGUILayout.TextArea(preset.Description);
                    }

                    GUILayout.FlexibleSpace();

                    DrawHeader("Tools");
                    if (GUILayout.Button("Import Legacy INI"))
                    {
                        string iniPath;
                        if (!string.IsNullOrEmpty(iniPath = EditorUtility.OpenFilePanel("Select ini file", rootPath, "ini")))
                        {
                            data.ImportLegacyIni(new IniParser.FileIniDataParser().ReadFile(iniPath));
                        }
                    }
                    else if (GUILayout.Button("Merge presets"))
                    {
                        string path;
                        if (!string.IsNullOrEmpty(path = EditorUtility.OpenFilePanel("Select preset file", rootPath, "json")))
                        {
                            data.LoadPresets(path, true);
                        }
                    }
                    else if (GUILayout.Button("Export localization table"))
                    {
                        string path;
                        if (!string.IsNullOrEmpty(path = EditorUtility.OpenFolderPanel("Select a folder", textPath, "")))
                        {
                            MakeTextDatabase(Path.Combine(path, string.Format("mod_{0}.txt", modName)));
                        }
                    }

                    EditorGUILayout.Space();
                });

                float areaWidth = 5 * position.width / 8;
                GUILayoutHelper.Area(new Rect(position.width - areaWidth, 0, areaWidth, position.height), () =>
                {
                    EditorGUILayout.Space();

                    if (data.Presets.Count > 0 && presets.index != -1)
                    {
                        if (GUILayout.SelectionGrid(IsPreset ? 1 : 0, new string[] { "Defaults", data.Presets[presets.index].Title }, 2) == 0)
                        {
                            if (IsPreset)
                            {
                                LoadPreset(-1);
                            }
                        }
                        else
                        {
                            if (currentPreset != presets.index)
                            {
                                LoadPreset(presets.index);
                            }
                        }
                    }

                    mainScrollPosition = GUILayoutHelper.ScrollView(mainScrollPosition, () =>
                    {
                        sections.DoLayoutList();

                        duplicateSections = duplicateKeys = false;
                        var sectionNames  = new List <string>();
                        foreach (var section in data.Sections)
                        {
                            section.Name = !string.IsNullOrEmpty(section.Name) ? section.Name.Replace(" ", string.Empty) : GetUniqueName(sectionNames, "Section");
                            sectionNames.Add(section.Name);

                            var keyNames = new List <string>();
                            foreach (var key in section.Keys)
                            {
                                key.Name = !string.IsNullOrEmpty(key.Name) ? key.Name.Replace(" ", string.Empty) : GetUniqueName(keyNames, "Key");
                                keyNames.Add(key.Name);
                            }

                            duplicateKeys |= DuplicatesDetected(keyNames);
                            this.keyNames.Add(keyNames);
                        }
                        this.sectionNames  = sectionNames;
                        duplicateSections |= DuplicatesDetected(sectionNames);
                    });

                    GUILayout.FlexibleSpace();
                    EditorGUILayout.Space();
                });
            });
        }
        public override void OnInspectorGUI()
        {
            GUISkin customSkin;
            Color   defaultColor = GUI.color;

            if (EditorGUIUtility.isProSkin == true)
            {
                customSkin = (GUISkin)Resources.Load("Editor\\MUI Skin Dark");
            }
            else
            {
                customSkin = (GUISkin)Resources.Load("Editor\\MUI Skin Light");
            }

            GUILayout.BeginHorizontal();
            GUI.backgroundColor = defaultColor;

            GUILayout.Box(new GUIContent(""), customSkin.FindStyle("Button Top Header"));

            GUILayout.EndHorizontal();
            GUILayout.Space(-42);

            GUIContent[] toolbarTabs = new GUIContent[3];
            toolbarTabs[0] = new GUIContent("Content");
            toolbarTabs[1] = new GUIContent("Resources");
            toolbarTabs[2] = new GUIContent("Settings");

            GUILayout.BeginHorizontal();
            GUILayout.Space(17);

            currentTab = GUILayout.Toolbar(currentTab, toolbarTabs, customSkin.FindStyle("Tab Indicator"));

            GUILayout.EndHorizontal();
            GUILayout.Space(-40);
            GUILayout.BeginHorizontal();
            GUILayout.Space(17);

            if (GUILayout.Button(new GUIContent("Content", "Content"), customSkin.FindStyle("Tab Content")))
            {
                currentTab = 0;
            }
            if (GUILayout.Button(new GUIContent("Resources", "Resources"), customSkin.FindStyle("Tab Resources")))
            {
                currentTab = 1;
            }
            if (GUILayout.Button(new GUIContent("Settings", "Settings"), customSkin.FindStyle("Tab Settings")))
            {
                currentTab = 2;
            }

            GUILayout.EndHorizontal();

            var buttonText         = serializedObject.FindProperty("buttonText");
            var buttonIcon         = serializedObject.FindProperty("buttonIcon");
            var clickEvent         = serializedObject.FindProperty("clickEvent");
            var hoverEvent         = serializedObject.FindProperty("hoverEvent");
            var normalText         = serializedObject.FindProperty("normalText");
            var normalImage        = serializedObject.FindProperty("normalImage");
            var useCustomContent   = serializedObject.FindProperty("useCustomContent");
            var enableButtonSounds = serializedObject.FindProperty("enableButtonSounds");
            var useHoverSound      = serializedObject.FindProperty("useHoverSound");
            var useClickSound      = serializedObject.FindProperty("useClickSound");
            var soundSource        = serializedObject.FindProperty("soundSource");
            var hoverSound         = serializedObject.FindProperty("hoverSound");
            var clickSound         = serializedObject.FindProperty("clickSound");
            var rippleParent       = serializedObject.FindProperty("rippleParent");
            var useRipple          = serializedObject.FindProperty("useRipple");
            var renderOnTop        = serializedObject.FindProperty("renderOnTop");
            var centered           = serializedObject.FindProperty("centered");
            var rippleShape        = serializedObject.FindProperty("rippleShape");
            var speed            = serializedObject.FindProperty("speed");
            var maxSize          = serializedObject.FindProperty("maxSize");
            var startColor       = serializedObject.FindProperty("startColor");
            var transitionColor  = serializedObject.FindProperty("transitionColor");
            var rippleUpdateMode = serializedObject.FindProperty("rippleUpdateMode");

            switch (currentTab)
            {
            case 0:
                GUILayout.BeginHorizontal(EditorStyles.helpBox);

                EditorGUILayout.LabelField(new GUIContent("Button Text"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                EditorGUILayout.PropertyField(buttonText, new GUIContent(""));

                GUILayout.EndHorizontal();

                if (useCustomContent.boolValue == false && buttonTarget.normalText != null)
                {
                    buttonTarget.normalText.text = buttonText.stringValue;
                }

                else if (useCustomContent.boolValue == false && buttonTarget.normalText == null)
                {
                    GUILayout.Space(2);
                    EditorGUILayout.HelpBox("'Text Object' is not assigned. Go to Resources tab and assign the correct variable.", MessageType.Error);
                }

                GUILayout.BeginHorizontal(EditorStyles.helpBox);

                EditorGUILayout.LabelField(new GUIContent("Button Icon"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                EditorGUILayout.PropertyField(buttonIcon, new GUIContent(""));

                GUILayout.EndHorizontal();

                if (useCustomContent.boolValue == false && buttonTarget.normalImage != null)
                {
                    buttonTarget.normalImage.sprite = buttonTarget.buttonIcon;
                }

                else if (useCustomContent.boolValue == false && buttonTarget.normalImage == null)
                {
                    GUILayout.Space(2);
                    EditorGUILayout.HelpBox("'Image Object' is not assigned. Go to Resources tab and assign the correct variable.", MessageType.Error);
                }

                if (enableButtonSounds.boolValue == true && useHoverSound.boolValue == true)
                {
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    EditorGUILayout.LabelField(new GUIContent("Hover Sound"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                    EditorGUILayout.PropertyField(hoverSound, new GUIContent(""));

                    GUILayout.EndHorizontal();
                }

                if (enableButtonSounds.boolValue == true && useClickSound.boolValue == true)
                {
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    EditorGUILayout.LabelField(new GUIContent("Click Sound"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                    EditorGUILayout.PropertyField(clickSound, new GUIContent(""));

                    GUILayout.EndHorizontal();
                }

                GUILayout.Space(4);
                EditorGUILayout.PropertyField(clickEvent, new GUIContent("On Click Event"), true);
                EditorGUILayout.PropertyField(hoverEvent, new GUIContent("On Hover Event"), true);
                break;

            case 1:
                GUILayout.BeginHorizontal(EditorStyles.helpBox);

                EditorGUILayout.LabelField(new GUIContent("Text Object"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                EditorGUILayout.PropertyField(normalText, new GUIContent(""));

                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal(EditorStyles.helpBox);

                EditorGUILayout.LabelField(new GUIContent("Image Object"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                EditorGUILayout.PropertyField(normalImage, new GUIContent(""));

                GUILayout.EndHorizontal();

                if (enableButtonSounds.boolValue == true)
                {
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    EditorGUILayout.LabelField(new GUIContent("Sound Source"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                    EditorGUILayout.PropertyField(soundSource, new GUIContent(""));

                    GUILayout.EndHorizontal();
                }

                if (useRipple.boolValue == true)
                {
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    EditorGUILayout.LabelField(new GUIContent("Ripple Parent"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                    EditorGUILayout.PropertyField(rippleParent, new GUIContent(""));

                    GUILayout.EndHorizontal();
                }

                break;

            case 2:
                GUILayout.BeginHorizontal(EditorStyles.helpBox);

                useCustomContent.boolValue = GUILayout.Toggle(useCustomContent.boolValue, new GUIContent("Use Custom Content"), customSkin.FindStyle("Toggle"));
                useCustomContent.boolValue = GUILayout.Toggle(useCustomContent.boolValue, new GUIContent(""), customSkin.FindStyle("Toggle Helper"));

                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal(EditorStyles.helpBox);

                enableButtonSounds.boolValue = GUILayout.Toggle(enableButtonSounds.boolValue, new GUIContent("Enable Button Sounds"), customSkin.FindStyle("Toggle"));
                enableButtonSounds.boolValue = GUILayout.Toggle(enableButtonSounds.boolValue, new GUIContent(""), customSkin.FindStyle("Toggle Helper"));

                GUILayout.EndHorizontal();

                if (enableButtonSounds.boolValue == true)
                {
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    useHoverSound.boolValue = GUILayout.Toggle(useHoverSound.boolValue, new GUIContent("Enable Hover Sound"), customSkin.FindStyle("Toggle"));
                    useHoverSound.boolValue = GUILayout.Toggle(useHoverSound.boolValue, new GUIContent(""), customSkin.FindStyle("Toggle Helper"));

                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    useClickSound.boolValue = GUILayout.Toggle(useClickSound.boolValue, new GUIContent("Enable Click Sound"), customSkin.FindStyle("Toggle"));
                    useClickSound.boolValue = GUILayout.Toggle(useClickSound.boolValue, new GUIContent(""), customSkin.FindStyle("Toggle Helper"));

                    GUILayout.EndHorizontal();

                    if (buttonTarget.soundSource == null)
                    {
                        EditorGUILayout.HelpBox("'Sound Source' is not assigned. Go to Resources tab or click the button to create a new audio source.", MessageType.Info);

                        if (GUILayout.Button("Create a new one", customSkin.button))
                        {
                            buttonTarget.soundSource = buttonTarget.gameObject.AddComponent(typeof(AudioSource)) as AudioSource;
                            currentTab = 2;
                        }
                    }
                }

                GUILayout.BeginVertical(EditorStyles.helpBox);
                GUILayout.Space(-2);
                GUILayout.BeginHorizontal();

                useRipple.boolValue = GUILayout.Toggle(useRipple.boolValue, new GUIContent("Use Ripple"), customSkin.FindStyle("Toggle"));
                useRipple.boolValue = GUILayout.Toggle(useRipple.boolValue, new GUIContent(""), customSkin.FindStyle("Toggle Helper"));

                GUILayout.EndHorizontal();
                GUILayout.Space(4);

                if (useRipple.boolValue == true)
                {
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    renderOnTop.boolValue = GUILayout.Toggle(renderOnTop.boolValue, new GUIContent("Render On Top"), customSkin.FindStyle("Toggle"));
                    renderOnTop.boolValue = GUILayout.Toggle(renderOnTop.boolValue, new GUIContent(""), customSkin.FindStyle("Toggle Helper"));

                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    centered.boolValue = GUILayout.Toggle(centered.boolValue, new GUIContent("Centered"), customSkin.FindStyle("Toggle"));
                    centered.boolValue = GUILayout.Toggle(centered.boolValue, new GUIContent(""), customSkin.FindStyle("Toggle Helper"));

                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    EditorGUILayout.LabelField(new GUIContent("Update Mode"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                    EditorGUILayout.PropertyField(rippleUpdateMode, new GUIContent(""));

                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    EditorGUILayout.LabelField(new GUIContent("Shape"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                    EditorGUILayout.PropertyField(rippleShape, new GUIContent(""));

                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    EditorGUILayout.LabelField(new GUIContent("Speed"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                    EditorGUILayout.PropertyField(speed, new GUIContent(""));

                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    EditorGUILayout.LabelField(new GUIContent("Max Size"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                    EditorGUILayout.PropertyField(maxSize, new GUIContent(""));

                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    EditorGUILayout.LabelField(new GUIContent("Start Color"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                    EditorGUILayout.PropertyField(startColor, new GUIContent(""));

                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    EditorGUILayout.LabelField(new GUIContent("Transition Color"), customSkin.FindStyle("Text"), GUILayout.Width(120));
                    EditorGUILayout.PropertyField(transitionColor, new GUIContent(""));

                    GUILayout.EndHorizontal();
                }

                GUILayout.EndVertical();
                break;
            }

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 21
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            Upgrade();

            if (inventoryManager == null)
            {
                inventoryManager = AdvGame.GetReferences().inventoryManager;
            }

            selectedCheckMethod = (SelectedCheckMethod)EditorGUILayout.EnumPopup("Check selected item is:", selectedCheckMethod);

            if (inventoryManager != null)
            {
                if (selectedCheckMethod == SelectedCheckMethod.InSpecificCategory)
                {
                    // Create a string List of the field's names (for the PopUp box)
                    List <string> labelList = new List <string>();

                    int i         = 0;
                    int binNumber = 0;
                    if (parameterID == -1)
                    {
                        binNumber = -1;
                    }

                    if (inventoryManager.bins != null && inventoryManager.bins.Count > 0)
                    {
                        foreach (InvBin _bin in inventoryManager.bins)
                        {
                            labelList.Add(_bin.id.ToString() + ": " + _bin.label);

                            // If a category has been removed, make sure selected is still valid
                            if (_bin.id == binID)
                            {
                                binNumber = i;
                            }

                            i++;
                        }

                        if (binNumber == -1)
                        {
                            ACDebug.LogWarning("Previously chosen category no longer exists!");
                            binNumber = 0;
                        }

                        binNumber = EditorGUILayout.Popup("Inventory category:", binNumber, labelList.ToArray());
                        binID     = inventoryManager.bins[binNumber].id;

                        includeLast = EditorGUILayout.Toggle("Include last-selected?", includeLast);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No inventory categories exist!", MessageType.Info);
                        binID = -1;
                    }
                }
                else if (selectedCheckMethod == SelectedCheckMethod.SpecificItem)
                {
                    // Create a string List of the field's names (for the PopUp box)
                    List <string> labelList = new List <string>();

                    int i         = 0;
                    int invNumber = 0;
                    if (parameterID == -1)
                    {
                        invNumber = -1;
                    }

                    if (inventoryManager.items.Count > 0)
                    {
                        foreach (InvItem _item in inventoryManager.items)
                        {
                            labelList.Add(_item.label);

                            // If an item has been removed, make sure selected variable is still valid
                            if (_item.id == invID)
                            {
                                invNumber = i;
                            }

                            i++;
                        }

                        if (invNumber == -1)
                        {
                            ACDebug.LogWarning("Previously chosen item no longer exists!");
                            invID = 0;
                        }

                        parameterID = Action.ChooseParameterGUI("Inventory item:", parameters, parameterID, ParameterType.InventoryItem);
                        if (parameterID >= 0)
                        {
                            invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                            invID     = -1;
                        }
                        else
                        {
                            invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());
                            invID     = inventoryManager.items[invNumber].id;
                        }

                        includeLast = EditorGUILayout.Toggle("Include last-selected?", includeLast);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No inventory items exist!", MessageType.Info);
                        invID = -1;
                    }
                }
            }
        }
Exemplo n.º 22
0
    void OnGUI()
    {
        if (m_Lutify == null)
        {
            return;             // Can happen when Unity is restarted and the LUT browser is still opened
        }
        // Header
        GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
        {
            EditorGUI.BeginChangeCheck();

            m_SelectedCollection = EditorGUILayout.Popup(m_SelectedCollection, m_CollectionMenu, EditorStyles.toolbarPopup, GUILayout.MaxWidth(170f));

            if (EditorGUI.EndChangeCheck())
            {
                m_ScrollView = Vector2.zero;
                m_Lutify._LastSelectedCategory = m_SelectedCollection;
            }

            GUILayout.FlexibleSpace();

            EditorGUI.BeginChangeCheck();

            m_Lutify._ThumbWidth = Mathf.RoundToInt(GUILayout.HorizontalSlider(m_Lutify._ThumbWidth, 100f, 300f, new GUIStyle("preSlider"), new GUIStyle("preSliderThumb"), GUILayout.Width(64f)));

            if (EditorGUI.EndChangeCheck())
            {
                InternalGUIUtility.RepaintGameView();
            }

            if (GUILayout.Button("?", EditorStyles.toolbarButton))
            {
                Application.OpenURL("http://www.thomashourdel.com/lutify/");
            }
        }
        GUILayout.EndHorizontal();

        // Component check
        if (!m_Lutify.enabled)
        {
            EditorGUILayout.HelpBox("Lutify is disabled ! Please enable the component get the LUT browser to work.", MessageType.Error);

            if (GUILayout.Button("Enable"))
            {
                m_Lutify.enabled = true;
            }

            return;
        }

        // Gallery
        List <Texture2D> luts = null;

        if (!m_Collections.TryGetValue(m_CollectionNames[m_SelectedCollection], out luts) || luts.Count == 0)
        {
            return;
        }

        m_ScrollView = GUILayout.BeginScrollView(m_ScrollView, false, false, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
        {
            int w       = Mathf.FloorToInt(position.width);
            int tw      = m_Lutify._ThumbWidth;
            int th      = m_Lutify._ThumbHeight;
            int spacing = 4;
            int margin  = 16;
            int c       = (w - margin) / (tw + spacing);

            GUILayout.BeginVertical();
            {
                GUILayout.Space(spacing);

                FilterMode filterMode  = m_CollectionFilters[m_SelectedCollection];
                bool       layoutState = false;
                int        j           = 0;

                for (int i = 0; i < luts.Count; i++)
                {
                    j++;

                    if (!layoutState)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        layoutState = true;
                    }

                    Rect r = GUILayoutUtility.GetRect(tw, th);

                    if (m_Lutify._PreviewRT != null)
                    {
                        DrawPreview(r, luts[i], filterMode);
                    }

                    if (j < c && c != 1 && i != luts.Count - 1)
                    {
                        GUILayout.Space(spacing);
                    }

                    if (layoutState && j == c)
                    {
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                        GUILayout.Space(spacing);
                        layoutState = false;
                        j           = 0;
                    }
                }

                if (layoutState && j < c)
                {
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }

                GUILayout.Space(spacing);
            }
            GUILayout.EndVertical();
        }
        GUILayout.EndScrollView();
    }
Exemplo n.º 23
0
        public override void OnInspectorGUI()
        {
            if (_effect == null)
            {
                return;
            }
            _effect.isDirty = false;

            EditorGUILayout.Separator();
            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
            GUILayout.Label(_headerTexture, GUILayout.ExpandWidth(true));
            GUI.skin.label.alignment = TextAnchor.MiddleLeft;
            if (!_effect.enabled)
            {
                EditorGUILayout.HelpBox("Beautify disabled.", MessageType.Info);
            }
            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal();
            DrawLabel("General Settings");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Quality", "The mobile variant is simply less accurate but faster."), GUILayout.Width(90));
            _effect.quality = (BEAUTIFY_QUALITY)EditorGUILayout.EnumPopup(_effect.quality);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Preset", "Quick configurations."), GUILayout.Width(90));
            _effect.preset = (BEAUTIFY_PRESET)EditorGUILayout.EnumPopup(_effect.preset);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Compare Mode", "Shows a side by side comparison."), GUILayout.Width(90));
            _effect.compareMode = EditorGUILayout.Toggle(_effect.compareMode);
            if (GUILayout.Button("Help", GUILayout.Width(50)))
            {
                EditorUtility.DisplayDialog("Help", "Beautify is a full-screen image processing effect that makes your scenes crisp, vivid and intense.\n\nMove the mouse over a setting for a short description or read the provided documentation (PDF) for details and tips.\n\nVisit kronnect.com for support and questions.\n\nPlease rate Beautify on the Asset Store! Thanks.", "Ok");
            }
            EditorGUILayout.EndHorizontal();

            if (_effect.compareMode)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Angle", "Angle of the separator line."), GUILayout.Width(90));
                _effect.compareLineAngle = EditorGUILayout.Slider(_effect.compareLineAngle, -Mathf.PI, Mathf.PI);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Width", "Width of the separator line."), GUILayout.Width(90));
                _effect.compareLineWidth = EditorGUILayout.Slider(_effect.compareLineWidth, 0.0001f, 0.05f);
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Separator();
            DrawLabel("Image Enhancement");

            if (_effect.cameraEffect != null && !_effect.cameraEffect.hdr)
            {
                EditorGUILayout.HelpBox("Some effects, like dither and bloom, works better with HDR enabled. Check your camera setting.", MessageType.Warning);
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Sharpen", "Sharpen intensity."), GUILayout.Width(90));
            _effect.sharpen = EditorGUILayout.Slider(_effect.sharpen, 0f, 12f);
            EditorGUILayout.EndHorizontal();

            if (_effect.cameraEffect != null && !_effect.cameraEffect.orthographic)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Min/Max Depth", "Any pixel outside this depth range won't be affected by sharpen. Reduce range to create a depth-of-field-like effect."), GUILayout.Width(120));
                float minDepth = _effect.sharpenMinDepth;
                float maxDepth = _effect.sharpenMaxDepth;
                EditorGUILayout.MinMaxSlider(ref minDepth, ref maxDepth, 0f, 1.1f);
                _effect.sharpenMinDepth = minDepth;
                _effect.sharpenMaxDepth = maxDepth;
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Depth Threshold", "Reduces sharpen if depth difference around a pixel exceeds this value. Useful to prevent artifacts around wires or thin objects."), GUILayout.Width(120));
                _effect.sharpenDepthThreshold = EditorGUILayout.Slider(_effect.sharpenDepthThreshold, 0f, 0.05f);
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("   Luminance Relax.", "Soften sharpen around a pixel with high contrast. Reduce this value to remove ghosting and protect fine drawings or wires over a flat surface."), GUILayout.Width(120));
            _effect.sharpenRelaxation = EditorGUILayout.Slider(_effect.sharpenRelaxation, 0f, 0.2f);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("   Clamp", "Maximum pixel adjustment."), GUILayout.Width(120));
            _effect.sharpenClamp = EditorGUILayout.Slider(_effect.sharpenClamp, 0f, 1f);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("   Motion Sensibility", "Increase to reduce sharpen to simulate a cheap motion blur and to reduce flickering when camera rotates or moves. This slider controls the amount of camera movement/rotation that contributes to sharpen reduction. Set this to 0 to disable this feature."), GUILayout.Width(120));
            _effect.sharpenMotionSensibility = EditorGUILayout.Slider(_effect.sharpenMotionSensibility, 0f, 1f);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Dither", "Simulates more colors than RGB quantization can produce. Removes banding artifacts in gradients, like skybox. This setting controls the dithering strength."), GUILayout.Width(90));
            _effect.dither = EditorGUILayout.Slider(_effect.dither, 0f, 0.2f);
            EditorGUILayout.EndHorizontal();

            if (_effect.cameraEffect != null && !_effect.cameraEffect.orthographic)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Min Depth", "Will only remove bands on pixels beyond this depth. Useful if you only want to remove sky banding (set this to 0.99)"), GUILayout.Width(120));
                _effect.ditherDepth = EditorGUILayout.Slider(_effect.ditherDepth, 0f, 1f);
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Separator();
            DrawLabel("Color Grading");

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Vibrance", "Improves pixels color depending on their saturation."), GUILayout.Width(90));
            _effect.saturate = EditorGUILayout.Slider(_effect.saturate, -2f, 3f);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Daltonize", "Similar to vibrance but mostly accentuate primary red, green and blue colors to compensate protanomaly (red deficiency), deuteranomaly (green deficiency) and tritanomaly (blue deficiency). This effect does not shift color hue hence it won't help completely red, green or blue color blindness. The effect will vary depending on each subject so this effect should be enabled on user demand."), GUILayout.Width(90));
            _effect.daltonize = EditorGUILayout.Slider(_effect.daltonize, 0f, 2f);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Tint", "Blends image with an optional color. Alpha specifies intensity."), GUILayout.Width(90));
            _effect.tintColor = EditorGUILayout.ColorField(_effect.tintColor);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Contrast", "Final image contrast adjustment. Allows you to create more vivid images."), GUILayout.Width(90));
            _effect.contrast = EditorGUILayout.Slider(_effect.contrast, 0.5f, 1.5f);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Brightness", "Final image brightness adjustment."), GUILayout.Width(90));
            _effect.brightness = EditorGUILayout.Slider(_effect.brightness, 0f, 2f);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();
            DrawLabel("Extra FX");

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Bloom", "Produces fringes of light extending from the borders of bright areas, contributing to the illusion of an extremely bright light overwhelming the camera or eye capturing the scene."), GUILayout.Width(90));
            _effect.bloom = EditorGUILayout.Toggle(_effect.bloom);
            if (_effect.bloom)
            {
                GUILayout.Label(new GUIContent("Debug", "Enable to see bloom/anamorphic channel."));
                _effect.bloomDebug = EditorGUILayout.Toggle(_effect.bloomDebug, GUILayout.Width(40));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Intensity", "Bloom multiplier."), GUILayout.Width(90));
                _effect.bloomIntensity = EditorGUILayout.Slider(_effect.bloomIntensity, 0f, 10f);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Threshold", "Brightness sensibility."), GUILayout.Width(90));
                _effect.bloomThreshold = EditorGUILayout.Slider(_effect.bloomThreshold, 0f, 5f);
                if (_effect.quality == BEAUTIFY_QUALITY.BestQuality)
                {
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label(new GUIContent("   Reduce Flicker", "Enables an additional filter to reduce excess of flicker."), GUILayout.Width(90));
                    _effect.bloomAntiflicker = EditorGUILayout.Toggle(_effect.bloomAntiflicker);
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label(new GUIContent("   Customize", "Edit bloom style parameters."), GUILayout.Width(90));
                    _effect.bloomCustomize = EditorGUILayout.Toggle(_effect.bloomCustomize);
                    if (_effect.bloomCustomize)
                    {
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label("   Presets", GUILayout.Width(90));
                        if (GUILayout.Button("Focused"))
                        {
                            _effect.SetBloomWeights(1f, 0.9f, 0.75f, 0.6f, 0.35f, 0.1f);
                        }
                        if (GUILayout.Button("Regular"))
                        {
                            _effect.SetBloomWeights(0.85f, 0.95f, 1f, 0.9f, 0.77f, 0.6f);
                        }
                        if (GUILayout.Button("Blurred"))
                        {
                            _effect.SetBloomWeights(0.2f, 0.4f, 0.6f, 0.75f, 0.9f, 1.0f);
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(new GUIContent("   Weight 1", "First layer bloom weight."), GUILayout.Width(90));
                        _effect.bloomWeight0 = EditorGUILayout.Slider(_effect.bloomWeight0, 0f, 1f);
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(new GUIContent("   Weight 2", "Second layer bloom weight."), GUILayout.Width(90));
                        _effect.bloomWeight1 = EditorGUILayout.Slider(_effect.bloomWeight1, 0f, 1f);
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(new GUIContent("   Weight 3", "Third layer bloom weight."), GUILayout.Width(90));
                        _effect.bloomWeight2 = EditorGUILayout.Slider(_effect.bloomWeight2, 0f, 1f);
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(new GUIContent("   Weight 4", "Fourth layer bloom weight."), GUILayout.Width(90));
                        _effect.bloomWeight3 = EditorGUILayout.Slider(_effect.bloomWeight3, 0f, 1f);
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(new GUIContent("   Weight 5", "Fifth layer bloom weight."), GUILayout.Width(90));
                        _effect.bloomWeight4 = EditorGUILayout.Slider(_effect.bloomWeight4, 0f, 1f);
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(new GUIContent("   Weight 6", "Sixth layer bloom weight."), GUILayout.Width(90));
                        _effect.bloomWeight5 = EditorGUILayout.Slider(_effect.bloomWeight5, 0f, 1f);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Anamorphic F.", "Also known as JJ Abrams flares, adds spectacular light streaks to your scene."), GUILayout.Width(90));
            if (_effect.quality != BEAUTIFY_QUALITY.BestQuality)
            {
                GUILayout.Label("(only available for 'best quality' setting)");
            }
            else
            {
                _effect.anamorphicFlares = EditorGUILayout.Toggle(_effect.anamorphicFlares);
            }
            if (_effect.anamorphicFlares && _effect.quality == BEAUTIFY_QUALITY.BestQuality)
            {
                if (!_effect.bloom)
                {
                    GUILayout.Label(new GUIContent("Debug", "Enable to see bloom/anamorphic flares channel."));
                    _effect.bloomDebug = EditorGUILayout.Toggle(_effect.bloomDebug, GUILayout.Width(40));
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Intensity", "Flares light multiplier."), GUILayout.Width(90));
                _effect.anamorphicFlaresIntensity = EditorGUILayout.Slider(_effect.anamorphicFlaresIntensity, 0f, 10f);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Threshold", "Brightness sensibility."), GUILayout.Width(90));
                _effect.anamorphicFlaresThreshold = EditorGUILayout.Slider(_effect.anamorphicFlaresThreshold, 0f, 5f);
                EditorGUILayout.EndHorizontal();
                if (_effect.quality == BEAUTIFY_QUALITY.BestQuality)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label(new GUIContent("   Reduce Flicker", "Enables an additional filter to reduce excess of flicker."), GUILayout.Width(90));
                    _effect.anamorphicFlaresAntiflicker = EditorGUILayout.Toggle(_effect.anamorphicFlaresAntiflicker);
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Spread", "Amplitude of the flares."), GUILayout.Width(90));
                _effect.anamorphicFlaresSpread = EditorGUILayout.Slider(_effect.anamorphicFlaresSpread, 0.1f, 2f);
                GUILayout.Label("Vertical");
                _effect.anamorphicFlaresVertical = EditorGUILayout.Toggle(_effect.anamorphicFlaresVertical, GUILayout.Width(20));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Tint", "Optional tint color for the anamorphic flares. Use color alpha component to blend between original color and the tint."), GUILayout.Width(90));
                _effect.anamorphicFlaresTint = EditorGUILayout.ColorField(_effect.anamorphicFlaresTint);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Lens Dirt", "Enables lens dirt effect which intensifies when looking to a light (uses the nearest light to camera). You can assign other dirt textures directly to the shader material with name 'Beautify'."), GUILayout.Width(90));
            _effect.lensDirt = EditorGUILayout.Toggle(_effect.lensDirt);
            EditorGUILayout.EndHorizontal();
            if (_effect.lensDirt)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Dirt Texture", "Texture used for the lens dirt effect."), GUILayout.Width(90));
                _effect.lensDirtTexture = (Texture2D)EditorGUILayout.ObjectField(_effect.lensDirtTexture, typeof(Texture2D), false);
                if (GUILayout.Button("?", GUILayout.Width(20)))
                {
                    EditorUtility.DisplayDialog("Lens Dirt Texture", "You can find additional lens dirt textures inside \nBeautify/Resources/Textures folder.", "Ok");
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Threshold", "This slider controls the visibility of lens dirt. A high value will make lens dirt only visible when looking directly towards a light source. A lower value will make lens dirt visible all time."), GUILayout.Width(90));
                _effect.lensDirtThreshold = EditorGUILayout.Slider(_effect.lensDirtThreshold, 0f, 1f);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Intensity", "This slider controls the maximum brightness of lens dirt effect."), GUILayout.Width(90));
                _effect.lensDirtIntensity = EditorGUILayout.Slider(_effect.lensDirtIntensity, 0f, 1f);
                EditorGUILayout.EndHorizontal();
            }

            if (_effect.vignetting || _effect.frame || _effect.outline || _effect.nightVision || _effect.thermalVision)
            {
                EditorGUILayout.HelpBox("Customize the effects below using color picker. Alpha has special meaning depending on effect. Read the tooltip moving the mouse over the effect name.", MessageType.Info);
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Vignetting", "Enables colored vignetting effect. Color alpha specifies intensity of effect."), GUILayout.Width(90));
            _effect.vignetting = EditorGUILayout.Toggle(_effect.vignetting);

            if (_effect.vignetting)
            {
                GUILayout.Label(new GUIContent("Color", "The color for the vignetting effect. Alpha specifies intensity of effect."), GUILayout.Width(40));
                _effect.vignettingColor = EditorGUILayout.ColorField(_effect.vignettingColor);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Circular Shape", "Ignores screen aspect ratio showing a circular shape."), GUILayout.Width(90));
                _effect.vignettingCircularShape = EditorGUILayout.Toggle(_effect.vignettingCircularShape);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Frame", "Enables colored frame effect. Color alpha specifies intensity of effect."), GUILayout.Width(90));
            _effect.frame = EditorGUILayout.Toggle(_effect.frame);

            if (_effect.frame)
            {
                GUILayout.Label(new GUIContent("Color", "The color for the frame effect. Alpha specifies intensity of effect."), GUILayout.Width(40));
                _effect.frameColor = EditorGUILayout.ColorField(_effect.frameColor);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Outline", "Enables outline (edge detection) effect. Color alpha specifies edge detection threshold."), GUILayout.Width(90));
            _effect.outline = EditorGUILayout.Toggle(_effect.outline);

            if (_effect.outline)
            {
                GUILayout.Label(new GUIContent("Color", "The color for the outline. Alpha specifies edge detection threshold."), GUILayout.Width(40));
                _effect.outlineColor = EditorGUILayout.ColorField(_effect.outlineColor);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Sepia", "Enables sepia color effect."), GUILayout.Width(90));
            _effect.sepia = EditorGUILayout.Toggle(_effect.sepia, GUILayout.Width(40));
            if (_effect.sepia)
            {
                GUILayout.Label("Intensity");
                _effect.sepiaIntensity = EditorGUILayout.Slider(_effect.sepiaIntensity, 0f, 1f);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Night Vision", "Enables night vision effect. Color alpha controls intensity. For a better result, enable Vignetting and set its color to (0,0,0,32)."), GUILayout.Width(90));
            _effect.nightVision = EditorGUILayout.Toggle(_effect.nightVision);
            if (_effect.nightVision)
            {
                GUILayout.Label(new GUIContent("Color", "The color for the night vision effect. Alpha controls intensity."), GUILayout.Width(40));
                _effect.nightVisionColor = EditorGUILayout.ColorField(_effect.nightVisionColor);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("Thermal Vision", "Enables thermal vision effect."), GUILayout.Width(90));
            _effect.thermalVision = EditorGUILayout.Toggle(_effect.thermalVision);
            EditorGUILayout.EndHorizontal();

            if (_effect.isDirty)
            {
                EditorUtility.SetDirty(target);
            }
        }
Exemplo n.º 24
0
        private void ShowVarGUI(List <GVar> vars, List <ActionParameter> parameters, ParameterType parameterType)
        {
            // Create a string List of the field's names (for the PopUp box)
            List <string> labelList = new List <string>();

            int i = 0;

            if (parameterID == -1)
            {
                variableNumber = -1;
            }

            if (vars.Count > 0)
            {
                foreach (GVar _var in vars)
                {
                    labelList.Add(_var.label);

                    // If a GlobalVar variable has been removed, make sure selected variable is still valid
                    if (_var.id == variableID)
                    {
                        variableNumber = i;
                    }

                    i++;
                }

                if (variableNumber == -1 && (parameters == null || parameters.Count == 0 || parameterID == -1))
                {
                    // Wasn't found (variable was deleted?), so revert to zero
                    ACDebug.LogWarning("Previously chosen variable no longer exists!");
                    variableNumber = 0;
                    variableID     = 0;
                }

                parameterID = Action.ChooseParameterGUI("Variable:", parameters, parameterID, parameterType);
                if (parameterID >= 0)
                {
                    //variableNumber = 0;
                    variableNumber = Mathf.Min(variableNumber, vars.Count - 1);
                    variableID     = -1;
                }
                else
                {
                    variableNumber = EditorGUILayout.Popup("Variable:", variableNumber, labelList.ToArray());
                    variableID     = vars [variableNumber].id;
                }

                string label = "Statement: ";

                if (vars [variableNumber].type == VariableType.Boolean)
                {
                    setVarMethodIntBool = (SetVarMethodIntBool)EditorGUILayout.EnumPopup("New value is:", setVarMethodIntBool);

                    label += "=";
                    if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere)
                    {
                        setParameterID = Action.ChooseParameterGUI(label, parameters, setParameterID, ParameterType.Boolean);
                        if (setParameterID < 0)
                        {
                            boolValue = (BoolValue)EditorGUILayout.EnumPopup(label, boolValue);
                        }
                    }
                    else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter)
                    {
                        ShowMecanimGUI();
                    }
                }
                if (vars [variableNumber].type == VariableType.PopUp)
                {
                    setVarMethod = (SetVarMethod)EditorGUILayout.EnumPopup("Method:", setVarMethod);

                    if (setVarMethod == SetVarMethod.Formula)
                    {
                        label += "=";

                        setParameterID = Action.ChooseParameterGUI(label, parameters, setParameterID, ParameterType.String);
                        if (setParameterID < 0)
                        {
                            formula = EditorGUILayout.TextField(label, formula);
                        }

                                                #if UNITY_WP8
                        EditorGUILayout.HelpBox("This feature is not available for Windows Phone 8.", MessageType.Warning);
                                                #endif
                    }
                    else if (setVarMethod == SetVarMethod.IncreaseByValue || setVarMethod == SetVarMethod.SetValue)
                    {
                        if (setVarMethod == SetVarMethod.IncreaseByValue)
                        {
                            label += "+=";
                        }
                        else if (setVarMethod == SetVarMethod.SetValue)
                        {
                            label += "=";
                        }

                        setParameterID = Action.ChooseParameterGUI(label, parameters, setParameterID, ParameterType.Integer);
                        if (setParameterID < 0)
                        {
                            if (setVarMethod == SetVarMethod.SetValue)
                            {
                                intValue = EditorGUILayout.Popup(label, intValue, vars[variableNumber].popUps);
                            }
                            else
                            {
                                intValue = EditorGUILayout.IntField(label, intValue);
                            }

                            if (setVarMethod == SetVarMethod.SetAsRandom && intValue < 0)
                            {
                                intValue = 0;
                            }
                        }
                    }
                }
                else if (vars [variableNumber].type == VariableType.Integer)
                {
                    setVarMethodIntBool = (SetVarMethodIntBool)EditorGUILayout.EnumPopup("New value is:", setVarMethodIntBool);

                    if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere)
                    {
                        setVarMethod = (SetVarMethod)EditorGUILayout.EnumPopup("Method:", setVarMethod);

                        if (setVarMethod == SetVarMethod.Formula)
                        {
                            label += "=";

                            setParameterID = Action.ChooseParameterGUI(label, parameters, setParameterID, ParameterType.String);
                            if (setParameterID < 0)
                            {
                                formula = EditorGUILayout.TextField(label, formula);
                            }

                                                        #if UNITY_WP8
                            EditorGUILayout.HelpBox("This feature is not available for Windows Phone 8.", MessageType.Warning);
                                                        #endif
                        }
                        else
                        {
                            if (setVarMethod == SetVarMethod.IncreaseByValue)
                            {
                                label += "+=";
                            }
                            else if (setVarMethod == SetVarMethod.SetValue)
                            {
                                label += "=";
                            }
                            else if (setVarMethod == SetVarMethod.SetAsRandom)
                            {
                                label += ("= 0 to");
                            }

                            setParameterID = Action.ChooseParameterGUI(label, parameters, setParameterID, ParameterType.Integer);
                            if (setParameterID < 0)
                            {
                                intValue = EditorGUILayout.IntField(label, intValue);

                                if (setVarMethod == SetVarMethod.SetAsRandom && intValue < 0)
                                {
                                    intValue = 0;
                                }
                            }
                        }
                    }
                    else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter)
                    {
                        ShowMecanimGUI();
                    }
                }
                else if (vars [variableNumber].type == VariableType.Float)
                {
                    setVarMethodIntBool = (SetVarMethodIntBool)EditorGUILayout.EnumPopup("New value is:", setVarMethodIntBool);

                    if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere)
                    {
                        setVarMethod = (SetVarMethod)EditorGUILayout.EnumPopup("Method:", setVarMethod);

                        if (setVarMethod == SetVarMethod.Formula)
                        {
                            label += "=";

                            setParameterID = Action.ChooseParameterGUI(label, parameters, setParameterID, ParameterType.String);
                            if (setParameterID < 0)
                            {
                                formula = EditorGUILayout.TextField(label, formula);
                            }

                                                        #if UNITY_WP8
                            EditorGUILayout.HelpBox("This feature is not available for Windows Phone 8.", MessageType.Warning);
                                                        #endif
                        }
                        else
                        {
                            if (setVarMethod == SetVarMethod.IncreaseByValue)
                            {
                                label += "+=";
                            }
                            else if (setVarMethod == SetVarMethod.SetValue)
                            {
                                label += "=";
                            }
                            else if (setVarMethod == SetVarMethod.SetAsRandom)
                            {
                                label += "= 0 to";
                            }

                            setParameterID = Action.ChooseParameterGUI(label, parameters, setParameterID, ParameterType.Float);
                            if (setParameterID < 0)
                            {
                                floatValue = EditorGUILayout.FloatField(label, floatValue);

                                if (setVarMethod == SetVarMethod.SetAsRandom && floatValue < 0f)
                                {
                                    floatValue = 0f;
                                }
                            }
                        }
                    }
                    else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter)
                    {
                        ShowMecanimGUI();
                    }
                }
                else if (vars [variableNumber].type == VariableType.String)
                {
                    setVarMethodString = (SetVarMethodString)EditorGUILayout.EnumPopup("New value is:", setVarMethodString);

                    label += "=";
                    if (setVarMethodString == SetVarMethodString.EnteredHere)
                    {
                        setParameterID = Action.ChooseParameterGUI(label, parameters, setParameterID, ParameterType.String);
                        if (setParameterID < 0)
                        {
                            stringValue = EditorGUILayout.TextField(label, stringValue);
                        }
                    }
                    else if (setVarMethodString == SetVarMethodString.SetAsMenuElementText)
                    {
                        menuName    = EditorGUILayout.TextField("Menu name:", menuName);
                        elementName = EditorGUILayout.TextField("Element name:", elementName);

                        slotNumberParameterID = Action.ChooseParameterGUI("Slot # (optional):", parameters, slotNumberParameterID, ParameterType.Integer);
                        if (slotNumberParameterID < 0)
                        {
                            slotNumber = EditorGUILayout.IntField("Slot # (optional):", slotNumber);
                        }
                    }
                }

                AfterRunningOption();
            }
            else
            {
                EditorGUILayout.HelpBox("No variables exist!", MessageType.Info);
                variableID     = -1;
                variableNumber = -1;
            }
        }
Exemplo n.º 25
0
        void OnGUI()
        {
            EditorGUILayout.BeginHorizontal();
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            if (Stage.Instruction == stage)
            {
                EditorGUILayout.HelpBox("Welcome to Avatar 8Track. This tool let's you automagically turn a folder of songs into a music player in your avatars radial menu.\n"
                                        + "Song Library Setup\n"
                                        + "   - Create a folder somewhere under Assets\n"
                                        + "   - Put all of your songs into that folder\n"
                                        + "        The folder name does not matter.\n"
                                        + "        All songs from the folder will be added\n"
                                        , MessageType.None, true);
                EditorGUILayout.HelpBox("Do not store anything but your songs in the Song Library, it may be deleted", MessageType.Warning, true);
                EditorGUILayout.HelpBox("One song library per avatar!", MessageType.Warning, true);
                EditorGUILayout.HelpBox("If you update the library with new songs just run the tool again", MessageType.Info, true);
                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

                // --- Avatar stuff ---
                EditorGUI.BeginChangeCheck();
                avatarIndex = EditorGUILayout.Popup("Avatar", avatarIndex, avatarKeys, EditorStyles.popup);
                if (EditorGUI.EndChangeCheck())
                {
                    expressionParameters = avatars[avatarKeys[avatarIndex]].expressionParameters;
                    expressionsMenu      = avatars[avatarKeys[avatarIndex]].expressionsMenu;
                    _8TrackEditor.SetFromAvatar(avatars[avatarKeys[avatarIndex]]);
                }
                //--- 8Track object
                EditorGUILayout.HelpBox("The 8Track object will hold all of your AudioClip Components."
                                        + "\nIt must be a first child of your avatar."
                                        + "\nThe name of the 8Track object will determine names for various assets."
                                        + "\nI highly recommend you use the default object.", MessageType.Info, true);
                EditorGUILayout.LabelField("The 8Track Object");
                _8TrackEditor._8TrackObject = (GameObject)EditorGUILayout.ObjectField(_8TrackEditor._8TrackObject, typeof(GameObject), true);
                if (null == _8TrackEditor._8TrackObject)
                {
                    _8trackValid = false;
                    if (GUILayout.Button("Create _8Track Object", GUILayout.Height(30)))
                    {
                        _8TrackEditor._8TrackObject = new GameObject("8Track");
                        _8TrackEditor._8TrackObject.transform.parent = _8TrackEditor.Avatar.transform;
                        Debug.Log($"Created new object for tracks [{_8TrackEditor._8TrackObject.name}]");
                    }
                    else
                    {
                        _8TrackEditor.SetFromAvatar(avatars[avatarKeys[avatarIndex]]);
                    }
                }
                else if (_8TrackEditor._8TrackObject.transform.parent != _8TrackEditor.Avatar.transform)
                {
                    EditorGUILayout.HelpBox("The 8Track object must be a child of the avatar selected", MessageType.Error, true);
                    _8trackValid = false;
                }
                else
                {
                    _8trackValid = true;
                }

                //set var
                if (null != _8TrackEditor._8TrackObject)
                {
                    _8TrackEditor.VolumeEPName = Avatar8Track.GetVarName(_8TrackEditor._8TrackObject, Avatar8Track.volumeEPNameSuffix);
                    _8TrackEditor.TrackEPName  = Avatar8Track.GetVarName(_8TrackEditor._8TrackObject, Avatar8Track.trackEPNameSuffix);
                }

                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

                //--- Parameters
                if (expressionValid)
                {
                    EditorGUILayout.HelpBox("A Integer and Float parameter will be added", MessageType.Info, true);
                }
                else if (null != expressionParameters)
                {
                    EditorGUILayout.HelpBox("The ExpressionParameters does not have space for a float and an int" + "\nYou can delete empty parameters to make room", MessageType.Error, true);
                    if (GUILayout.Button("Delete Empty Parameters", GUILayout.Height(30)))
                    {
                        for (int i = 0; i < expressionParameters.parameters.Length; i++)
                        {
                            if (string.IsNullOrEmpty(expressionParameters.parameters[i].name))
                            {
                                ArrayUtility.RemoveAt <VRCExpressionParameters.Parameter>(ref expressionParameters.parameters, i);
                                i--;
                            }
                        }
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("An ExpressionParameters object is required", MessageType.Error, true);
                }

                EditorGUILayout.LabelField("VRC ExpressionParameters File");
                expressionParameters = (VRCExpressionParameters)EditorGUILayout.ObjectField(expressionParameters, typeof(VRCExpressionParameters), true);

                if (null != expressionParameters && null != _8TrackEditor._8TrackObject)
                {
                    int cost = VRCExpressionParameters.TypeCost(VRCExpressionParameters.ValueType.Int) + VRCExpressionParameters.TypeCost(VRCExpressionParameters.ValueType.Float);
                    VRCExpressionParameters.Parameter[] parameters = expressionParameters.parameters;
                    foreach (VRCExpressionParameters.Parameter parameter in parameters)
                    {
                        if (parameter.name == _8TrackEditor.VolumeEPName)
                        {
                            cost -= VRCExpressionParameters.TypeCost(VRCExpressionParameters.ValueType.Float);
                        }
                        else if (parameter.name == _8TrackEditor.TrackEPName)
                        {
                            cost -= VRCExpressionParameters.TypeCost(VRCExpressionParameters.ValueType.Int);
                        }
                    }
                    expressionValid = expressionParameters.CalcTotalCost() + cost <= VRCExpressionParameters.MAX_PARAMETER_COST;
                }
                else
                {
                    expressionValid = null != expressionParameters;
                }
                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

                //--- Menu
                if (menuValid)
                {
                    EditorGUILayout.HelpBox("Which VRCExpressionsMenu do you want the SubMenu added to", MessageType.Info, true);
                }
                else if (null != expressionsMenu)
                {
                    EditorGUILayout.HelpBox("The VRCExpressionsMenu is full", MessageType.Error, true);
                }

                if (null == expressionsMenu)
                {
                    EditorGUILayout.HelpBox("ExpressionsMenu is not set", MessageType.Warning, true);
                }

                EditorGUILayout.LabelField("VRC Expressions Menu File");
                expressionsMenu = (VRCExpressionsMenu)EditorGUILayout.ObjectField(expressionsMenu, typeof(VRCExpressionsMenu), true);

                if (null != expressionsMenu && null != _8TrackEditor._8TrackObject)
                {
                    menuValid = expressionsMenu.controls.Count < VRCExpressionsMenu.MAX_CONTROLS;
                    foreach (VRCExpressionsMenu.Control control in expressionsMenu.controls)
                    {
                        if (control.name == _8TrackEditor._8TrackObject.name)
                        {
                            menuValid = true;
                        }
                    }
                }
                else
                {
                    menuValid = true;
                }


                if (null != expressionParameters && menuValid && expressionValid && _8trackValid)
                {
                    Button(Stage._8Track, "Setup");
                }
            }
            else if (Stage._8Track == stage)
            {
                _8TrackEditor.OnGUI();
                Button(Stage.Instruction, "Back <-");
                if (_8TrackEditor.IsValid())
                {
                    Button(Stage.Burn, "Continue ->");
                }
            }

            if (Stage.Burn == stage)
            {
                EditorGUILayout.HelpBox("Read Carefully!!!!!!", MessageType.Error);
                EditorGUILayout.HelpBox("This will break the 8Track functionality for any other avatar this song library has been added to previously."
                                        + "\nDuplicate the song library if you want to add it to a separate avatar.", MessageType.Warning);
                EditorGUILayout.HelpBox("Avatar 8Tracks lets you update your song library by re-running it on the same avatar."
                                        + "\nfor convenience it auto-detects and deletes assets it has created previously and replaces them."
                                        + "\nDouble check the following items below were not manually edited by you."
                                        , MessageType.Warning);
                EditorGUILayout.LabelField("FX Controller Layers, Expression Parameters, and Expression Menu Controls with the following names", EditorStyles.wordWrappedLabel);
                EditorGUILayout.LabelField($"     [{_8TrackEditor.TrackEPName}]", EditorStyles.boldLabel);
                EditorGUILayout.LabelField($"     [{_8TrackEditor.VolumeEPName}]", EditorStyles.boldLabel);
                EditorGUILayout.LabelField($"     [{_8TrackEditor._8TrackObject.name}]", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox($"All AnimationClips, and ExpressionsMenus will be deleted in [{GetAssetDirectory(_8TrackEditor.AudioClip, true)}]", MessageType.Warning);
                Button(Stage._8Track, "Back <-");
                if (GUILayout.Button("Accept And Burn Tracks", GUILayout.Height(30)))
                {
                    try {
                        string songLibrary = GetAssetDirectory(_8TrackEditor.AudioClip, false);
                        CleanSongLibrary(songLibrary);
                        List <AudioClip> libAssets = GetSongList(songLibrary);
                        _8TrackEditor.BurnTracks(libAssets);
                        VRC_Actions(songLibrary, libAssets, _8TrackEditor);
                        AssetDatabase.SaveAssets();
                        EditorUtility.DisplayDialog("Avatar 8Tracks", "You're ready to rock", "great");
                        this.Close();
                    } catch (System.Exception e) {
                        EditorUtility.DisplayDialog("so... this happened", e.Message, "sorry");
                        Debug.LogException(e);
                        this.Close();
                    }
                }
                DrawEnd();
            }
            else
            {
                DrawEnd();
            }
        }
Exemplo n.º 26
0
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        TCP2_GUI.HeaderBig("TOONY COLORS PRO 2 - SHADER GENERATOR");
        TCP2_GUI.HelpButton("Shader Generator");
        EditorGUILayout.EndHorizontal();
        TCP2_GUI.Separator();

        float lW = EditorGUIUtility.labelWidth;

        EditorGUIUtility.labelWidth = 105f;

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.BeginHorizontal();
        mCurrentShader = EditorGUILayout.ObjectField("Current Shader:", mCurrentShader, typeof(Shader), false) as Shader;
        if (EditorGUI.EndChangeCheck())
        {
            if (mCurrentShader != null)
            {
                LoadCurrentConfigFromShader(mCurrentShader);
            }
        }
        if (GUILayout.Button("Copy Shader", EditorStyles.miniButton, GUILayout.Width(78f)))
        {
            CopyShader();
        }
        if (GUILayout.Button("New Shader", EditorStyles.miniButton, GUILayout.Width(76f)))
        {
            NewShader();
        }
        EditorGUILayout.EndHorizontal();

        if (mIsModified)
        {
            EditorGUILayout.HelpBox("It looks like this shader has been modified externally/manually. Updating it will overwrite the changes.", MessageType.Warning);
        }

        if (mUserShaders != null && mUserShaders.Length > 0)
        {
            EditorGUI.BeginChangeCheck();
            int   prevChoice = mConfigChoice;
            Color gColor     = GUI.color;
            GUI.color = mDirtyConfig ? gColor * Color.yellow : GUI.color;
            GUILayout.BeginHorizontal();
            mConfigChoice = EditorGUILayout.Popup("Load Shader:", mConfigChoice, mUserShadersLabels.ToArray());
            if (GUILayout.Button("◄", EditorStyles.miniButtonLeft, GUILayout.Width(22)))
            {
                mConfigChoice--;
                if (mConfigChoice < 1)
                {
                    mConfigChoice = mUserShaders.Length;
                }
            }
            if (GUILayout.Button("►", EditorStyles.miniButtonRight, GUILayout.Width(22)))
            {
                mConfigChoice++;
                if (mConfigChoice > mUserShaders.Length)
                {
                    mConfigChoice = 1;
                }
            }
            GUILayout.EndHorizontal();
            GUI.color = gColor;
            if (EditorGUI.EndChangeCheck() && prevChoice != mConfigChoice)
            {
                bool load = true;
                if (mDirtyConfig)
                {
                    if (mCurrentShader != null)
                    {
                        load = EditorUtility.DisplayDialog("TCP2 : Shader Generation", "You have unsaved changes for the following shader:\n\n" + mCurrentShader.name + "\n\nDiscard the changes and load a new shader?", "Yes", "No");
                    }
                    else
                    {
                        load = EditorUtility.DisplayDialog("TCP2 : Shader Generation", "You have unsaved changes.\n\nDiscard the changes and load a new shader?", "Yes", "No");
                    }
                }

                if (load)
                {
                    //New Shader
                    if (mConfigChoice == 0)
                    {
                        NewShader();
                    }
                    else
                    {
                        //Load selected Shader
                        Shader selectedShader = mUserShaders[mConfigChoice - 1];
                        mCurrentShader = selectedShader;
                        LoadCurrentConfigFromShader(mCurrentShader);
                    }
                }
                else
                {
                    //Revert choice
                    mConfigChoice = prevChoice;
                }
            }
        }

        Template = EditorGUILayout.ObjectField("Template:", Template, typeof(TextAsset), false) as TextAsset;
        EditorGUIUtility.labelWidth = lW;

        if (mCurrentConfig == null)
        {
            NewShader();
        }
        mGUIEnabled = GUI.enabled;

        //Name & Filename
        TCP2_GUI.Header("NAME");
        GUI.enabled = (mCurrentShader == null);
        EditorGUI.BeginChangeCheck();
        mCurrentConfig.ShaderName = EditorGUILayout.TextField(new GUIContent("Shader Name", "Path will indicate how to find the Shader in Unity's drop-down list"), mCurrentConfig.ShaderName);
        mCurrentConfig.ShaderName = Regex.Replace(mCurrentConfig.ShaderName, @"[^a-zA-Z0-9 _!/]", "");
        if (EditorGUI.EndChangeCheck() && mAutoNames)
        {
            AutoNames();
        }
        GUI.enabled &= !mAutoNames;
        EditorGUILayout.BeginHorizontal();
        mCurrentConfig.Filename = EditorGUILayout.TextField("File Name", mCurrentConfig.Filename);
        mCurrentConfig.Filename = Regex.Replace(mCurrentConfig.Filename, @"[^a-zA-Z0-9 _!/]", "");
        GUILayout.Label(".shader", GUILayout.Width(50f));
        EditorGUILayout.EndHorizontal();
        GUI.enabled = mGUIEnabled;

        Space();

        //########################################################################################################
        // FEATURES
        TCP2_GUI.Header("FEATURES");

        //Scroll view
        mScrollPosition = EditorGUILayout.BeginScrollView(mScrollPosition);
        EditorGUI.BeginChangeCheck();

#if DEBUG_MODE
        //Custom Lighting
        GUISingleFeature("CUSTOM_LIGHTING_FORCE", "Custom Lighting", "Use an inline custom lighting model, allowing more flexibility per shader over lighting");
        GUISingleFeature("VERTEX_FUNC", "Vertex Function", "Force custom vertex function in surface shader");
        Space();
        //----------------------------------------------------------------
#endif
        //Ramp
        GUIMultipleFeatures("Ramp Style", "Defines the transitioning between dark and lit areas of the model", "Slider Ramp|", "Texture Ramp|TEXTURE_RAMP");
        //Textured Threshold
        GUISingleFeature("TEXTURED_THRESHOLD", "Textured Threshold", "Adds a textured variation to the highlight/shadow threshold, allowing handpainting like effects for example");
        Space();
        //----------------------------------------------------------------
        //Detail
        GUISingleFeature("DETAIL_TEX", "Detail Texture");
        //Detail UV2
        GUISingleFeature("DETAIL_UV2", "Use UV2 coordinates", "Use second texture coordinates for the detail texture", HasFeat("DETAIL_TEX"), true);
        GUIMask("Detail Mask", null, "DETAIL_MASK", "DETAIL_MASK_CHANNEL", "DETAIL_MASK", HasFeatOr("DETAIL_TEX"), true);
        Space();
        //----------------------------------------------------------------
        //Color Mask
        GUIMask("Color Mask", "Adds a mask to the main Color", "COLORMASK", "COLORMASK_CHANNEL", "COLORMASK", true, helpTopic: "Color Mask");
        Space();
        //----------------------------------------------------------------
        //Vertex Colors
        GUISingleFeature("VCOLORS", "Vertex Colors", "Multiplies the color with vertex colors");
        //Texture Blend
        GUISingleFeature("VCOLORS_BLENDING", "Vertex Texture Blending", "Enables 2-way texture blending based on the mesh's vertex color alpha");
        Space();
        //----------------------------------------------------------------
        //Self-Illumination
        GUIMask("Self-Illumination Map", null, "ILLUMIN_MASK", "ILLUMIN_MASK_CHANNEL", "ILLUMINATION", helpTopic: "Self-Illumination Map");
        //Self-Illumination Color
        GUISingleFeature("ILLUM_COLOR", "Self-Illumination Color", null, HasFeat("ILLUMINATION"), true);
        Space();
        //----------------------------------------------------------------
        //Bump
        GUISingleFeature("BUMP", "Normal/Bump map", helpTopic: "normal_bump_map_sg");
        //Parallax
        GUISingleFeature("PARALLAX", "Parallax/Height map", null, HasFeat("BUMP"), true);
        Space();
        //----------------------------------------------------------------
        //Occlusion
//		GUISingleFeature("OCCLUSION", "Occlusion Map", "Use an Occlusion Map that will be multiplied with the Ambient lighting");
        //Occlusion RGB
//		GUISingleFeature("OCCL_RGB", "Use RGB map", "Use the RGB channels for Occlusion Map if enabled, use Alpha channel is disabled", HasFeat("OCCLUSION"), true);
//		Space();
        //----------------------------------------------------------------
        //Specular
        GUIMultipleFeaturesHelp("Specular", null, "specular_sg", "Off|", "Regular|SPECULAR", "Anisotropic|SPECULAR_ANISOTROPIC");
        if (HasFeatAnd("FORCE_SM2", "SPECULAR_ANISOTROPIC"))
        {
            EditorGUILayout.HelpBox("Anisotropic Specular will not compile with Shader Model 2!\n(too many instructions used)", MessageType.Warning);
        }
        //Specular Mask
        GUIMask("Specular Mask", "Enables specular mask (gloss map)", "SPEC_MASK", "SPEC_MASK_CHANNEL", "SPECULAR_MASK", HasFeatOr("SPECULAR", "SPECULAR_ANISOTROPIC"), true);
        //Specular Shininess Mask
        GUIMask("Shininess Mask", null, "SPEC_SHIN_MASK", "SPEC_SHIN_MASK_CHANNEL", "SPEC_SHIN_MASK", HasFeatOr("SPECULAR", "SPECULAR_ANISOTROPIC"), true);
        //Cartoon Specular
        GUISingleFeature("SPECULAR_TOON", "Cartoon Specular", "Enables clear delimitation of specular color", HasFeatOr("SPECULAR", "SPECULAR_ANISOTROPIC"), true);
        Space();
        //----------------------------------------------------------------
        //Reflection
        GUISingleFeature("REFLECTION", "Reflection", "Enables cubemap reflection", helpTopic: "reflection_sg");
        //Reflection Mask
        GUIMask("Reflection Mask", null, "REFL_MASK", "REFL_MASK_CHANNEL", "REFL_MASK", HasFeatOr("REFLECTION"), true);
#if UNITY_5
        //Unity5 Reflection Probes
        GUISingleFeature("U5_REFLPROBE", "Reflection Probes (Unity5)", "Pick reflection from Unity 5 Reflection Probes", HasFeat("REFLECTION"), true, helpTopic: "Reflection Probes");
#endif
        //Reflection Color
        GUISingleFeature("REFL_COLOR", "Reflection Color", "Enables reflection color control", HasFeat("REFLECTION"), true);
        //Reflection Roughness
        GUISingleFeature("REFL_ROUGH", "Reflection Roughness", "Simulates reflection roughness using the Cubemap's LOD levels\n\nREQUIRES MipMaps ENABLED IN THE CUBEMAP TEXTURE!", HasFeat("REFLECTION") && !HasFeat("U5_REFLPROBE"), true);
        //Rim Reflection
        GUISingleFeature("RIM_REFL", "Rim Reflection/Fresnel", "Reflection will be multiplied by rim lighting, resulting in a fresnel-like effect", HasFeat("REFLECTION"), true);
        Space();
        //----------------------------------------------------------------
        //Cubemap Ambient
        GUIMultipleFeaturesInternal("Custom Ambient", "Custom ambient lighting", new string[] { "Off|", "Cubemap Ambient|CUBE_AMBIENT", "Directional Ambient|DIRAMBIENT" });
        Space();
        //----------------------------------------------------------------
        //Independent Shadows
        GUISingleFeature("INDEPENDENT_SHADOWS", "Independent Shadows", "Disable shadow color influence for cast shadows");
        Space();
        //----------------------------------------------------------------
        //Rim
        GUIMultipleFeaturesInternal("Rim", "Rim effects (fake light coming from behind the model)", new string[] { "Off|", "Rim Lighting|RIM", "Rim Outline|RIM_OUTLINE" }, !(HasFeatAnd("REFLECTION", "RIM_REFL")), false, "rim_sg");
        if (HasFeat("REFLECTION") && HasFeat("RIM_REFL"))
        {
            TCP2_ShaderGeneratorUtils.ToggleSingleFeature(mCurrentConfig.Features, "RIM", true);
        }
        //Vertex Rim
        GUISingleFeature("RIM_VERTEX", "Vertex Rim", "Compute rim lighting per-vertex (faster but innacurate)", HasFeatOr("RIM", "RIM_OUTLINE"), true);
        //Directional Rim
        GUISingleFeature("RIMDIR", "Directional Rim", null, HasFeatOr("RIM", "RIM_OUTLINE"), true);
        //Rim Mask
        GUIMask("Rim Mask", null, "RIM_MASK", "RIM_MASK_CHANNEL", "RIM_MASK", HasFeatOr("RIM", "RIM_OUTLINE"), true);
        Space();
        //----------------------------------------------------------------
        //MatCap
        GUIMultipleFeaturesHelp("MatCap", "MatCap effects (fast fake reflection using a spherical texture)", "matcap_sg", "Off|", "MatCap Add|MATCAP_ADD", "MatCap Multiply|MATCAP_MULT");
        //MatCap Mask
        GUIMask("MatCap Mask", null, "MASK_MC", "MASK_MC_CHANNEL", "MASK_MC", HasFeatOr("MATCAP_ADD", "MATCAP_MULT"), true);
        //MatCap Color
        GUISingleFeature("MC_COLOR", "MatCap Color", null, HasFeatOr("MATCAP_ADD", "MATCAP_MULT"), true);
        Space();
        //----------------------------------------------------------------
        //Sketch
        GUIMultipleFeatures("Sketch", "Sketch texture overlay on the shadowed areas\nOverlay: regular texture overlay\nGradient: used for halftone-like effects", "Off|", "Sketch Overlay|SKETCH", "Sketch Gradient|SKETCH_GRADIENT");
        //Sketch Blending
        GUIMultipleFeaturesInternal("Sketch Blending", "Defines how to blend the Sketch texture with the model",
                                    new string[] { "Regular|", "Color Burn|SKETCH_COLORBURN" },
                                    HasFeat("SKETCH") && !HasFeat("SKETCH_GRADIENT"), true, null, false, 166);
        //Sketch Anim
        GUISingleFeature("SKETCH_ANIM", "Animated Sketch", "Animates the sketch overlay texture, simulating a hand-drawn animation style",
                         HasFeatOr("SKETCH", "SKETCH_GRADIENT"), true);
        //Sketch Vertex
        GUISingleFeature("SKETCH_VERTEX", "Vertex Coords", "Compute screen coordinates in vertex shader (faster but can cause distortions)\nIf disabled will compute in pixel shader (slower)",
                         HasFeatOr("SKETCH", "SKETCH_GRADIENT"), true);
        //Sketch Scale
        GUISingleFeature("SKETCH_SCALE", "Scale with model", "If enabled, overlay texture scale will depend on model's distance from view",
                         HasFeatOr("SKETCH", "SKETCH_GRADIENT"), true);
        Space();
        //----------------------------------------------------------------
        //Outline
        GUIMultipleFeatures("Outline", "Outline around the model", "Off|", "Opaque Outline|OUTLINE", "Blended Outline|OUTLINE_BLENDING");
        Space();
        //----------------------------------------------------------------
        //Lightmaps
        GUISingleFeature("LIGHTMAP", "TCP2 Lightmap", "Will use TCP2's lightmap decoding, affecting it with ramp and color settings", helpTopic: "Lightmap");
        Space();
        //----------------------------------------------------------------
        //Alpha Blending
        GUISingleFeature("ALPHA", "Alpha Blending");
        //Alpha Testing
        GUISingleFeature("CUTOUT", "Alpha Testing (Cutout)");
        Space();
        //----------------------------------------------------------------
        //Culling
        int cull = TCP2_ShaderGeneratorUtils.HasFeatures(mCurrentConfig, "CULL_FRONT") ? 1 : TCP2_ShaderGeneratorUtils.HasFeatures(mCurrentConfig, "CULL_OFF") ? 2 : 0;
        EditorGUILayout.BeginHorizontal();
        TCP2_GUI.SubHeader("Culling", "Defines how to cull faces", cull > 0, 166);
        cull = EditorGUILayout.Popup(cull, new string[] { "Default", "Front", "Off (double-sided)" });
        TCP2_ShaderGeneratorUtils.ToggleSingleFeature(mCurrentConfig.Features, "CULL_FRONT", cull == 1);
        TCP2_ShaderGeneratorUtils.ToggleSingleFeature(mCurrentConfig.Features, "CULL_OFF", cull == 2);
        EditorGUILayout.EndHorizontal();
        Space();
        //----------------------------------------------------------------

        //########################################################################################################
        // FLAGS
        TCP2_GUI.Header("FLAGS");
        GUISingleFlag("addshadow", "Add Shadow Passes", "Force the shader to have the Shadow Caster and Collector passes.\nCan help if shadows don't work properly with the shader");
        GUISingleFlag("fullforwardshadows", "Full Forward Shadows", "Enable support for all shadow types in Forward rendering path");
#if UNITY_5
        GUISingleFlag("noshadow", "Disable Shadows", "Disables all shadow receiving support in this shader");
        GUISingleFlag("nofog", "Disable Fog", "Disables Unity Fog support.\nCan help if you run out of vertex interpolators and don't need lightmaps!");
#endif
        GUISingleFlag("nolightmap", "Disable Lightmaps", "Disables all lightmapping support in this shader.\nCan help if you run out of vertex interpolators and don't need lightmaps!");
        GUISingleFlag("noambient", "Disable Ambient Lighting", "Enable support for all shadow types in Forward rendering path", !HasFeatOr("DIRAMBIENT", "CUBE_AMBIENT", "OCCLUSION"));
        GUISingleFlag("novertexlights", "Disable Vertex Lighting", "Disable vertex lights and spherical harmonics (light probes)");
        GUISingleFeature("FORCE_SM2", "Force Shader Model 2", "Compile with Shader Model 2 target. Useful for (very) old GPU compatibility, but some features may not work with it.", showHelp: false);

        TCP2_GUI.Header("FLAGS (Mobile-friendly)", null, true);
        GUISingleFlag("noforwardadd", "One Directional Light", "Use additive lights as vertex lights.\nRecommended for Mobile");
#if UNITY_5
        GUISingleFlag("interpolateview", "Vertex View Dir", "Calculate view direction per-vertex instead of per-pixel.\nRecommended for Mobile");
#else
        GUISingleFlag("approxview", "Vertex View Dir", "Calculate view direction per-vertex instead of per-pixel.\nRecommended for Mobile");
#endif
        GUISingleFlag("halfasview", "Half as View", "Pass half-direction vector into the lighting function instead of view-direction.\nFaster but inaccurate.\nRecommended for Specular, but use Vertex Rim to optimize Rim Effects instead");

#if DEBUG_MODE
        TCP2_GUI.SeparatorBig();
        GUILayout.BeginHorizontal();
        mDebugText = EditorGUILayout.TextField("Debug", mDebugText);
        if (GUILayout.Button("Add Feature", EditorStyles.miniButtonLeft, GUILayout.Width(80f)))
        {
            mCurrentConfig.Features.Add(mDebugText);
        }
        if (GUILayout.Button("Add Flag", EditorStyles.miniButtonRight, GUILayout.Width(80f)))
        {
            mCurrentConfig.Flags.Add(mDebugText);
        }

        GUILayout.EndHorizontal();
        GUILayout.Label("Features:");
        GUILayout.BeginHorizontal();
        int count = 0;
        for (int i = 0; i < mCurrentConfig.Features.Count; i++)
        {
            if (count >= 3)
            {
                count = 0;
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
            }
            count++;
            if (GUILayout.Button(mCurrentConfig.Features[i], EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                mCurrentConfig.Features.RemoveAt(i);
                break;
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.Label("Flags:");
        GUILayout.BeginHorizontal();
        count = 0;
        for (int i = 0; i < mCurrentConfig.Flags.Count; i++)
        {
            if (count >= 3)
            {
                count = 0;
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
            }
            count++;
            if (GUILayout.Button(mCurrentConfig.Flags[i], EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                mCurrentConfig.Flags.RemoveAt(i);
                break;
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.Label("Keywords:");
        GUILayout.BeginHorizontal();
        count = 0;
        foreach (KeyValuePair <string, string> kvp in mCurrentConfig.Keywords)
        {
            if (count >= 3)
            {
                count = 0;
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
            }
            count++;
            if (GUILayout.Button(kvp.Key + ":" + kvp.Value, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                mCurrentConfig.Keywords.Remove(kvp.Key);
                break;
            }
        }
        GUILayout.EndHorizontal();

        //----------------------------------------------------------------
#endif

        //Update config
        if (EditorGUI.EndChangeCheck())
        {
            int newHash = mCurrentConfig.ToHash();
            if (newHash != mCurrentHash)
            {
                mDirtyConfig = true;
            }
            else
            {
                mDirtyConfig = false;
            }
        }

        //Scroll view
        EditorGUILayout.EndScrollView();

        Space();

        //GENERATE

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
#if DEBUG_MODE
        if (GUILayout.Button("Re-Generate All", GUILayout.Width(120f), GUILayout.Height(30f)))
        {
            float progress = 0;
            float total    = mUserShaders.Length;
            foreach (Shader s in mUserShaders)
            {
                progress++;
                EditorUtility.DisplayProgressBar("Hold On", "Generating Shader: " + s.name, progress / total);

                mCurrentShader = null;
                LoadCurrentConfigFromShader(s);
                if (mCurrentShader != null && mCurrentConfig != null)
                {
                    TCP2_ShaderGeneratorUtils.Compile(mCurrentConfig, Template.text, false, !mOverwriteConfigs, mIsModified);
                }
            }
            EditorUtility.ClearProgressBar();
        }
#endif
        if (GUILayout.Button(mCurrentShader == null ? "Generate Shader" : "Update Shader", GUILayout.Width(120f), GUILayout.Height(30f)))
        {
            if (Template == null)
            {
                EditorUtility.DisplayDialog("TCP2 : Shader Generation", "Can't generate shader: no Template file defined!\n\nYou most likely want to link the TCP2_User.txt file to the Template field in the Shader Generator.", "Ok");
                return;
            }

            Shader generatedShader = TCP2_ShaderGeneratorUtils.Compile(mCurrentConfig, Template.text, true, !mOverwriteConfigs, mIsModified);
            ReloadUserShaders();
            if (generatedShader != null)
            {
                mDirtyConfig = false;
                LoadCurrentConfigFromShader(generatedShader);
                mIsModified = false;
            }
        }
        EditorGUILayout.EndHorizontal();
        TCP2_GUI.Separator();

        // OPTIONS
        TCP2_GUI.Header("OPTIONS");

        GUILayout.BeginHorizontal();
        mSelectGeneratedShader = GUILayout.Toggle(mSelectGeneratedShader, new GUIContent("Select Generated Shader", "Will select the generated file in the Project view"), GUILayout.Width(180f));
        mAutoNames             = GUILayout.Toggle(mAutoNames, new GUIContent("Automatic Name", "Will automatically generate the shader filename based on its UI name"), GUILayout.ExpandWidth(false));
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        mOverwriteConfigs = GUILayout.Toggle(mOverwriteConfigs, new GUIContent("Always overwrite shaders", "Overwrite shaders when generating/updating (no prompt)"), GUILayout.Width(180f));
        mHideDisabled     = GUILayout.Toggle(mHideDisabled, new GUIContent("Hide disabled fields", "Hide properties settings when they cannot be accessed"), GUILayout.ExpandWidth(false));
        GUILayout.EndHorizontal();
        EditorGUI.BeginChangeCheck();
        mLoadAllShaders = GUILayout.Toggle(mLoadAllShaders, new GUIContent("Reload Shaders from all Project", "Load shaders from all your Project folders instead of just Toony Colors Pro 2.\nEnable it if you move your generated shader files outside of the default TCP2 Generated folder."), GUILayout.ExpandWidth(false));
        if (EditorGUI.EndChangeCheck())
        {
            ReloadUserShaders();
        }

        TCP2_ShaderGeneratorUtils.SelectGeneratedShader = mSelectGeneratedShader;
    }
Exemplo n.º 27
0
        private void OnGUI()
        {
            EditorGUILayout.HelpBox("Copy , Clear Humanoid Collider", MessageType.Info);
            EditorTools.DrawLabelWithColorInBox("Copy", Color.green);

            m_Src = EditorGUILayout.ObjectField("Source", m_Src, typeof(GameObject), true) as GameObject;
            m_Des = EditorGUILayout.ObjectField("Destination", m_Des, typeof(GameObject), true) as GameObject;

            // If your humanoid character has same "bone" name
            if (GUILayout.Button("Copy Line-Sphere With Same Hierarchy", GUILayout.MinHeight(25)))
            {
                if (m_Src == null || m_Des == null)
                {
                    EditorTools.ShowMessage("Src or Des is Null...");
                }
                else
                {
                    FTPColliderTools.CopyLineSphereColliderWithSameHierarchy(m_Src, m_Des);
                }
            }
            // If your humanoid character has unsame "bone" name you can use Avatar to copy Collider
            if (GUILayout.Button("Copy Line-Sphere with Avatar Settings", GUILayout.MinHeight(25)))
            {
                if (m_Src == null || m_Des == null)
                {
                    EditorTools.ShowMessage("Src or Des is Null...");
                }
                else
                {
                    FTPColliderTools.CopyLineSphereColliderWithAvatar(m_Src, m_Des);
                }
            }

            EditorTools.DrawSpace(4);
            EditorTools.DrawLabelWithColorInBox("Clear", Color.green);
            m_ClearHumanoidColliderTarget = EditorGUILayout.ObjectField("Clear Target", m_ClearHumanoidColliderTarget, typeof(GameObject), true) as GameObject;
            // clear line-sphere collider
            if (GUILayout.Button("Clear Line-Sphere Collider", GUILayout.MinHeight(25)))
            {
                FTPColliderTools.ClearLineSphereCollider(m_ClearHumanoidColliderTarget);
            }

            // clear normal box or other real collider
            // just clear bone collider with avatar bone map
            if (GUILayout.Button("Clear Normal Collider", GUILayout.MinHeight(25)))
            {
                if (m_ClearHumanoidColliderTarget != null)
                {
                    Animator animator = m_ClearHumanoidColliderTarget.GetComponent <Animator>();
                    if (animator == null || !animator.isHuman || animator.avatar == null)
                    {
                        EditorTools.ShowMessage("Collider Target Need Animator to get avatar bone map.check Collider target is the Animator root?" +
                                                "And We need Humanoid Target and with Avatar set");
                    }
                    else
                    {
                        if (EditorUtility.DisplayDialog("Message", "Clear Humanoid Normal Collider with Avatar Bone?", "OK", "Cancel"))
                        {
                            if (newAvatarBoneData == null)
                            {
                                newAvatarBoneData = new HumanBodyBoneReferenceData();
                            }
                            newAvatarBoneData.ResetReference();
                            newAvatarBoneData.MapHumanAvatarToBoneReferences(m_ClearHumanoidColliderTarget.transform, animator);

                            foreach (var bone in newAvatarBoneData._dicBones)
                            {
                                if (bone.Value != null)
                                {
                                    Collider[] colliders = bone.Value.GetComponents <Collider>();
                                    for (int i = 0; i < colliders.Length; i++)
                                    {
                                        Object.DestroyImmediate(colliders[i]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        private void DrawFinished()
        {
            EditorGUILayout.Space();

            if (creator.Result == ExtensionServiceCreator.CreateResult.Error)
            {
                EditorGUILayout.HelpBox("There were errors during the creation process:", MessageType.Error);
                DrawCreationLog();

                EditorGUILayout.Space();
                if (GUILayout.Button("Start over"))
                {
                    creator.ResetState();
                }

                // All done, bail early
                return;
            }

            EditorGUILayout.HelpBox("Your service scripts have been created.", MessageType.Info);

            if (!registered)
            {
                EditorGUILayout.LabelField("Would you like to register this service in your current MixedRealityToolkit profile?", EditorStyles.miniLabel);

                // Check to see whether it's possible to register the profile
                bool canRegisterProfile = true;
                if (MixedRealityToolkit.Instance == null || !MixedRealityToolkit.Instance.HasActiveProfile)
                {
                    EditorGUILayout.HelpBox("Toolkit has no active profile. Can't register service.", MessageType.Warning);
                    canRegisterProfile = false;
                }
                else if (MixedRealityToolkit.Instance.ActiveProfile.RegisteredServiceProvidersProfile == null)
                {
                    EditorGUILayout.HelpBox("Toolkit has no RegisteredServiceProvidersProfile. Can't register service.", MessageType.Warning);
                    canRegisterProfile = false;
                }

                EditorGUILayout.Space();
                using (new EditorGUILayout.HorizontalScope())
                {
                    using (new EditorGUI.DisabledGroupScope(!canRegisterProfile))
                    {
                        if (GUILayout.Button("Register"))
                        {
                            RegisterServiceWithActiveMixedRealityProfile();
                        }
                    }

                    if (GUILayout.Button("Not Now"))
                    {
                        creator.ResetState();
                    }
                }
            }
            else
            {
                EditorGUILayout.LabelField("Your service is now registered. Scripts can access this service like so:", EditorStyles.miniLabel);

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.TextField(creator.SampleCode);
                    if (GUILayout.Button("Copy Sample Code", EditorStyles.miniButton))
                    {
                        EditorGUIUtility.systemCopyBuffer = creator.SampleCode;
                    }
                }

                EditorGUILayout.Space();
                if (GUILayout.Button("Create new service"))
                {
                    creator.ResetState();
                }
            }
        }
    public override void OnInspectorGUI()
    {
        serObj.Update();

        EditorGUILayout.LabelField("Converts textures into color lookup volumes (for grading)", EditorStyles.miniLabel);

        //EditorGUILayout.LabelField("Change Lookup Texture (LUT):");
        //EditorGUILayout.BeginHorizontal ();
        //Rect r = GUILayoutUtility.GetAspectRect(1.0ff);

        Rect r; Texture2D t;

        //EditorGUILayout.Space();
        tempClutTex2D = EditorGUILayout.ObjectField(" Based on", tempClutTex2D, typeof(Texture2D), false) as Texture2D;
        if (tempClutTex2D == null)
        {
            t = AssetDatabase.LoadMainAssetAtPath(((ColorCorrectionLookup)target).basedOnTempTex) as Texture2D;
            if (t)
            {
                tempClutTex2D = t;
            }
        }

        Texture2D tex = tempClutTex2D;

        if (tex && (target as ColorCorrectionLookup).basedOnTempTex != AssetDatabase.GetAssetPath(tex))
        {
            EditorGUILayout.Separator();
            if (!(target as ColorCorrectionLookup).ValidDimensions(tex))
            {
                EditorGUILayout.HelpBox("Invalid texture dimensions!\nPick another texture or adjust dimension to e.g. 256x16.", MessageType.Warning);
            }
            else if (GUILayout.Button("Convert and Apply"))
            {
                string          path            = AssetDatabase.GetAssetPath(tex);
                TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
                bool            doImport        = textureImporter.isReadable == false;
                if (textureImporter.mipmapEnabled == true)
                {
                    doImport = true;
                }

                if (doImport)
                {
                    textureImporter.isReadable    = true;
                    textureImporter.mipmapEnabled = false;
                    AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
                    //tex = AssetDatabase.LoadMainAssetAtPath(path);
                }

                (target as ColorCorrectionLookup).Convert(tex, path);
            }
        }

        if ((target as ColorCorrectionLookup).basedOnTempTex != "")
        {
            EditorGUILayout.HelpBox("Using " + (target as ColorCorrectionLookup).basedOnTempTex, MessageType.Info);
            t = AssetDatabase.LoadMainAssetAtPath(((ColorCorrectionLookup)target).basedOnTempTex) as Texture2D;
            if (t)
            {
                r        = GUILayoutUtility.GetLastRect();
                r        = GUILayoutUtility.GetRect(r.width, 20);
                r.x     += r.width * 0.05f / 2.0f;
                r.width *= 0.95f;
                GUI.DrawTexture(r, t);
                GUILayoutUtility.GetRect(r.width, 4);
            }
        }

        //EditorGUILayout.EndHorizontal ();

        serObj.ApplyModifiedProperties();
    }
Exemplo n.º 30
0
		override public void OnInspectorGUI () {
			if (serializedObject.isEditingMultipleObjects) {
				if (needsReset) {
					needsReset = false;
					foreach (var o in targets) {
						var bf = (BoneFollower)o;
						bf.Initialize();
						bf.LateUpdate();
					}
					SceneView.RepaintAll();
				}

				EditorGUI.BeginChangeCheck();
				DrawDefaultInspector();
				needsReset |= EditorGUI.EndChangeCheck();
				return;
			}

			if (needsReset && Event.current.type == EventType.Layout) {
				targetBoneFollower.Initialize();
				targetBoneFollower.LateUpdate();
				needsReset = false;
				SceneView.RepaintAll();
			}
			serializedObject.Update();

			// Find Renderer
			if (skeletonRenderer.objectReferenceValue == null) {
				SkeletonRenderer parentRenderer = targetBoneFollower.GetComponentInParent<SkeletonRenderer>();
				if (parentRenderer != null && parentRenderer.gameObject != targetBoneFollower.gameObject) {
					skeletonRenderer.objectReferenceValue = parentRenderer;
					Debug.Log("Inspector automatically assigned BoneFollower.SkeletonRenderer");
				}
			}

			EditorGUILayout.PropertyField(skeletonRenderer);
			var skeletonRendererReference = skeletonRenderer.objectReferenceValue as SkeletonRenderer;
			if (skeletonRendererReference != null) {
				if (skeletonRendererReference.gameObject == targetBoneFollower.gameObject) {
					skeletonRenderer.objectReferenceValue = null;
					EditorUtility.DisplayDialog("Invalid assignment.", "BoneFollower can only follow a skeleton on a separate GameObject.\n\nCreate a new GameObject for your BoneFollower, or choose a SkeletonRenderer from a different GameObject.", "Ok");
				}
			}

			if (!targetBoneFollower.valid) {
				needsReset = true;
			}

			if (targetBoneFollower.valid) {
				EditorGUI.BeginChangeCheck();
				EditorGUILayout.PropertyField(boneName);
				needsReset |= EditorGUI.EndChangeCheck();

				EditorGUILayout.PropertyField(followBoneRotation);
				EditorGUILayout.PropertyField(followZPosition);
				EditorGUILayout.PropertyField(followLocalScale);
				EditorGUILayout.PropertyField(followSkeletonFlip);

				BoneFollowerInspector.RecommendRigidbodyButton(targetBoneFollower);
			} else {
				var boneFollowerSkeletonRenderer = targetBoneFollower.skeletonRenderer;
				if (boneFollowerSkeletonRenderer == null) {
					EditorGUILayout.HelpBox("SkeletonRenderer is unassigned. Please assign a SkeletonRenderer (SkeletonAnimation or SkeletonAnimator).", MessageType.Warning);
				} else {
					boneFollowerSkeletonRenderer.Initialize(false);

					if (boneFollowerSkeletonRenderer.skeletonDataAsset == null)
						EditorGUILayout.HelpBox("Assigned SkeletonRenderer does not have SkeletonData assigned to it.", MessageType.Warning);

					if (!boneFollowerSkeletonRenderer.valid)
						EditorGUILayout.HelpBox("Assigned SkeletonRenderer is invalid. Check target SkeletonRenderer, its SkeletonDataAsset or the console for other errors.", MessageType.Warning);
				}
			}

			var current = Event.current;
			bool wasUndo = (current.type == EventType.ValidateCommand && current.commandName == "UndoRedoPerformed");
			if (wasUndo)
				targetBoneFollower.Initialize();

			serializedObject.ApplyModifiedProperties();
		}