Beispiel #1
0
        void OnGUI()
        {
            LoadFilePaths();
            if (settings == null)
            {
                this.LoadDefaultPageControllerSettings();
                EnumFileCreator.CreateOrOverwriteEnum("PagesEnum", PageNames.ToArray(), PagesEnumPath);
                pageTemplatePrefab = AssetDatabase.LoadAssetAtPath <GameObject> (PageTemplatePath);
            }
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
            PageNavEditorWindow.Settings = settings;
            this.titleContent            = new GUIContent("PageNav Settings");
            GUIStyle myStyle = new GUIStyle();

            myStyle.fontSize         = 20;
            myStyle.normal.textColor = GUI.skin.label.normal.textColor;
            GUILayout.Label("  ", myStyle);
            GUILayout.Label("  PageController Settings", myStyle);
            GUILayout.Label("  ", myStyle);
            GUI.enabled = false;
            settings    = (PageNavSettings)EditorGUILayout.ObjectField("PageNav Settings", settings, typeof(PageNavSettings), false);
            GUI.enabled = true;

            if (GUILayout.Button("Create PageNav in open scene"))
            {
                CreatePageNavInScene();
            }

            ShowPagesSection();

            EditorGUILayout.EndScrollView();
        }
Beispiel #2
0
        void LoadDefaultPageControllerSettings()
        {
            LoadFilePaths();
            string path = PageNavEditorWindow.PathRoot + "/FrameWorkFiles/PageNavSettings.asset";

            if (settings == null)
            {
                if (!File.Exists(path))
                {
                    if (!File.Exists("Assets/Resources"))
                    {
                        Directory.CreateDirectory("Assets/Resources");
                    }
                    settings = CreateAsset <PageNavSettings> (path);
                }
                else
                {
                    settings = AssetDatabase.LoadAssetAtPath <PageNavSettings> (path);
                }
            }
            PagesEnumPath                = settings.PagesEnumPath;
            PagesPath                    = settings.PagesPath;
            PageTemplatePath             = settings.PageTemplatePath;
            PageNavtemplatePath          = settings.PageNavtemplatePath;
            PageNavEditorWindow.Settings = settings;
        }
Beispiel #3
0
        // Draw the property inside the given rect
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            settingsPath  = PageNavEditorWindow.PathRoot + "/FrameWorkFiles/PageNavSettings.asset";
            PagesEnumPath = PageNavEditorWindow.PathRoot + "/FrameWorkFiles/Scripts";
            label         = EditorGUI.BeginProperty(position, label, property);
            label.text    = property.displayName;
            Rect pos = position;

            position        = EditorGUI.PrefixLabel(pos, label);
            position.width /= 2;
            bool hasChanged = false;

            EditorGUI.BeginChangeCheck();
            PagesEnum newEnum = (PagesEnum)EditorGUI.EnumPopup(position, ((PagesEnum)property.enumValueIndex));

            if (EditorGUI.EndChangeCheck())
            {
                hasChanged = true;
            }
            position.x += position.width;
            if (GUI.Button(position, "Show") && newEnum != PagesEnum.None)
            {
                if (settings == null)
                {
                    settings = AssetDatabase.LoadAssetAtPath <PageNavSettings> (settingsPath);
                }
                EditorGUIUtility.PingObject(settings.PagesPrefabs[(int)newEnum - 1]);
            }
            if (property.enumValueIndex >= property.enumNames.Length)
            {
                if (PageNavEditorWindow.PageNames != null)
                {
                    EnumFileCreator.CreateOrOverwriteEnum("PagesEnum", PageNavEditorWindow.PageNames.ToArray(), PagesEnumPath);
                }
                else
                {
                    Debug.LogWarning("it is necessary to rebuild the Pages Enum");
                    Debug.Log("it is necessary to rebuild the Pages Enum");
                }
                property.enumValueIndex = 0;
            }
            if (hasChanged)
            {
                try{
                    property.enumValueIndex = (int)newEnum;
                }catch (Exception e) {
                    property.enumValueIndex = 0;
                }
            }
            EditorGUI.EndProperty();
        }