コード例 #1
0
        private void OnGUI()
        {
            Title();
            EditorWindowUtils.BeginVertical();
            scrollPosition = EditorWindowUtils.BeginScrollView(scrollPosition);
            switch (_page)
            {
            case Page.Welcome:
                welcomeWindow.OnGUI();
                break;

            case Page.Release_Notes:
                releaseNotesWindow.OnGUI();
                break;

            case Page.Log_Settings:
                logSettingsWindow.OnGUI();
                break;

            default:
                welcomeWindow.OnGUI();
                break;
            }
            EditorWindowUtils.EndScrollView();
            EditorWindowUtils.EndVertical();
            EditorWindowUtils.Space(10);
            UndoableInputFieldUtils.BoolFieldWithTooltip(() => { forceShow = EditorPrefs.GetBool(editor_About_ForcePopUp, false); return(forceShow); }, b => { forceShow = b; EditorPrefs.SetBool(editor_About_ForcePopUp, b); }, "  Automatically Pop-up", "Display this window when opening Unity. Alternatively, this widow can be opened from LeiaLoft-> About", window);
            EditorWindowUtils.Space(10);
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.LabelField("Set media here. Do NOT use VideoPlayer.");
            EditorGUILayout.HelpBox("Media filename should have format [name...]_[cols]x[rows].[fmt]", MessageType.Info);

            // display several properties using same style
            SerializedProperty[] leiaMediaProperties = new [] { leiaMediaVideoURL, leiaMediaVideoClip, leiaMediaTexture };
            bool[] leiaMediaPropertyUpdated          = new bool[leiaMediaProperties.Length];
            for (int i = 0; i < leiaMediaProperties.Length; i++)
            {
                // show LeiaMedia properties, and record changes in their values
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(leiaMediaProperties[i]);
                leiaMediaPropertyUpdated[i] = EditorGUI.EndChangeCheck();
            }

            EditorGUILayout.PropertyField(automaticAspectRatio);

            if (automaticAspectRatio.boolValue)
            {
                EditorGUILayout.HelpBox("Max scale of gameObject before gameObject is shrunk to meet media's aspect ratio", MessageType.Info);
                EditorGUILayout.PropertyField(maxScaleBeforeAspectRatio);
            }

            if (GUILayout.Button("Move to Convergence Plane") && lmv != null)
            {
                lmv.ProjectOntoZDP();
            }

            // newer style for newer properties - UndoableInputFieldUtils
            // in addition to changing LeiaMedia URL/video/texture, allow users to change cols / rows
            UndoableInputFieldUtils.ImmediateIntField(
                // get
                () => lmv.ActiveLeiaMediaCols,
                // set
                (int val) => { lmv.ActiveLeiaMediaCols = val; },
                // label
                propertyStringResources[(int)propertyStringIDs.LeiaMediaCol][1],
                serializedObject.targetObject);

            UndoableInputFieldUtils.ImmediateIntField(
                // get
                () => lmv.ActiveLeiaMediaRows,
                // set
                (int val) => { lmv.ActiveLeiaMediaRows = val; },
                // label
                propertyStringResources[(int)propertyStringIDs.LeiaMediaRow][1],
                serializedObject.targetObject);

            serializedObject.ApplyModifiedProperties();

            // if we detected a change in LeiaMedia property, then after applying property update we should also update cols / rows
            for (int i = 0; i < leiaMediaProperties.Length; i++)
            {
                // if user updated a URL/texture/video property
                if (leiaMediaPropertyUpdated[i])
                {
                    string filename = lmv.ActiveLeiaMediaName;
                    int    cols, rows = 0;
                    bool   parsed = StringExtensions.TryParseColsRowsFromFilename(filename, out cols, out rows);

                    // if we could parse cols and rows from the LeiaMedia name
                    if (parsed)
                    {
                        // then set cols and rows on LeiaMediaViewer
                        lmv.ActiveLeiaMediaCols = cols;
                        lmv.ActiveLeiaMediaRows = rows;
                    }
                }
            }
        }