Пример #1
0
    private void HeaderBoxMain(string title, ref bool drawGizmos, ref bool defaultInspector, Texture2D scrIcon, MonoBehaviour target, int height = 22)
    {
        EditorGUILayout.BeginVertical(FGUI_Resources.HeaderBoxStyle);

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button(new GUIContent(scrIcon), EditorStyles.label, new GUILayoutOption[2] {
            GUILayout.Width(height - 2), GUILayout.Height(height - 2)
        }))
        {
            MonoScript script = MonoScript.FromMonoBehaviour(target);
            if (script)
            {
                EditorGUIUtility.PingObject(script);
            }
            drawHeaderFoldout = !drawHeaderFoldout;
        }

        if (GUILayout.Button(title, FGUI_Resources.GetTextStyle(14, true, TextAnchor.MiddleLeft), GUILayout.Height(height)))
        {
            MonoScript script = MonoScript.FromMonoBehaviour(target);
            if (script)
            {
                EditorGUIUtility.PingObject(script);
            }
            drawHeaderFoldout = !drawHeaderFoldout;
        }

        if (EditorGUIUtility.currentViewWidth > 326)
        {
            // Youtube channel button
            if (GUILayout.Button(new GUIContent(FGUI_Resources.Tex_Tutorials, "Open FImpossible Creations Channel with tutorial videos in your web browser"), FGUI_Resources.ButtonStyle, new GUILayoutOption[2] {
                GUILayout.Width(height), GUILayout.Height(height)
            }))
            {
                Application.OpenURL("https://www.youtube.com/c/FImpossibleCreations");
            }
        }

        if (EditorGUIUtility.currentViewWidth > 292)
        {
            // Store site button
            if (GUILayout.Button(new GUIContent(FGUI_Resources.Tex_Website, "Open FImpossible Creations Asset Store Page inside your web browser"), FGUI_Resources.ButtonStyle, new GUILayoutOption[2] {
                GUILayout.Width(height), GUILayout.Height(height)
            }))
            {
                Application.OpenURL("https://assetstore.unity.com/publishers/37262");
            }
        }

        // Manual file button
        if (_manualFile == null)
        {
            _manualFile = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(MonoScript.FromMonoBehaviour(target))) + "/Spine Animator User Manual.pdf");
        }
        if (_manualFile)
        {
            if (GUILayout.Button(new GUIContent(FGUI_Resources.Tex_Manual, "Open .PDF user manual file for Spine Animator"), FGUI_Resources.ButtonStyle, new GUILayoutOption[2] {
                GUILayout.Width(height), GUILayout.Height(height)
            }))
            {
                EditorGUIUtility.PingObject(_manualFile);
                Application.OpenURL(Application.dataPath + "/" + AssetDatabase.GetAssetPath(_manualFile).Replace("Assets/", ""));
            }
        }

        FGUI_Inspector.DrawSwitchButton(ref drawGizmos, FGUI_Resources.Tex_GizmosOff, FGUI_Resources.Tex_Gizmos, "Toggle drawing gizmos on character in scene window", height, height, true);
        FGUI_Inspector.DrawSwitchButton(ref drawHeaderFoldout, FGUI_Resources.Tex_LeftFold, FGUI_Resources.Tex_DownFold, "Toggle to view additional options for foldouts", height, height);

        EditorGUILayout.EndHorizontal();

        if (drawHeaderFoldout)
        {
            FGUI_Inspector.DrawUILine(0.07f, 0.1f, 1, 4, 0.99f);

            EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginChangeCheck();
            choosedLang = (ELangs)EditorGUILayout.EnumPopup(choosedLang, new GUIStyle(EditorStyles.layerMaskField)
            {
                fixedHeight = 0
            }, new GUILayoutOption[2] {
                GUILayout.Width(80), GUILayout.Height(22)
            });
            if (EditorGUI.EndChangeCheck())
            {
                PlayerPrefs.SetInt("FimposLang", (int)choosedLang);
                SetupLangs();
            }

            GUILayout.FlexibleSpace();

            bool hierSwitchOn = PlayerPrefs.GetInt("AnimsH", 1) == 1;
            FGUI_Inspector.DrawSwitchButton(ref hierSwitchOn, FGUI_Resources.Tex_HierSwitch, null, "Switch drawing small icons in hierarchy", height, height, true);
            PlayerPrefs.SetInt("AnimsH", hierSwitchOn ? 1 : 0);

            if (GUILayout.Button(new GUIContent(FGUI_Resources.Tex_Rename, "Change component title to yours (current: '" + Get._editor_Title + "'"), FGUI_Resources.ButtonStyle, new GUILayoutOption[2] {
                GUILayout.Width(height), GUILayout.Height(height)
            }))
            {
                string filename = EditorUtility.SaveFilePanelInProject("Type your title (no file will be created)", Get._editor_Title, "", "Type your title (no file will be created)");
                if (!string.IsNullOrEmpty(filename))
                {
                    filename = System.IO.Path.GetFileNameWithoutExtension(filename);
                    if (!string.IsNullOrEmpty(filename))
                    {
                        Get._editor_Title = filename; serializedObject.ApplyModifiedProperties();
                    }
                }
            }

            // Default inspector switch
            FGUI_Inspector.DrawSwitchButton(ref drawNewInspector, FGUI_Resources.Tex_AB, null, "Switch GUI Style to old / new", height, height, true);
            if (!drawNewInspector && drawDefaultInspector)
            {
                drawDefaultInspector = false;
            }

            // Old new UI Button
            FGUI_Inspector.DrawSwitchButton(ref defaultInspector, FGUI_Resources.Tex_Default, null, "Toggle inspector view to default inspector.\n\nIf you ever edit source code of Look Animator and add custom variables, you can see them by entering this mode, also sometimes there can be additional/experimental variables to play with.", height, height);
            if (!drawNewInspector && drawDefaultInspector)
            {
                drawNewInspector = false;
            }

            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.EndVertical();
    }