public override void OnInspectorGUI()
 {
     DrawDefaultInspector();
     if (GUILayout.Button(Preview.togglePreviewShortcut))
     {
         Preview.TogglePreview();
     }
 }
Exemple #2
0
        public override void OnInspectorGUI()
        {
            // psuedo custom inspector
            SerializedProperty prop = serializedObject.GetIterator();
            Holoplay           hp   = (Holoplay)target;
            // account for the first prop being the script
            bool firstProp = true;

            GUI.enabled = false;
            if (prop.NextVisible(true))
            {
                do
                {
                    // sections
                    if (!advanced.DoSection(prop))
                    {
                        continue;
                    }
                    if (!quilt.DoSection(prop))
                    {
                        continue;
                    }
                    if (!gizmo.DoSection(prop))
                    {
                        continue;
                    }
                    if (!events.DoSection(prop))
                    {
                        continue;
                    }
                    if (!optimization.DoSection(prop))
                    {
                        continue;
                    }

                    // skip custom quilt settings if preset not set to custom
                    if (prop.name == "customQuiltSettings" && hp.quiltPreset != Quilt.Preset.Custom)
                    {
                        var qs = Quilt.GetPreset(hp.quiltPreset);
                        EditorGUILayout.LabelField("Quilt Size: ", qs.quiltWidth + " x " + qs.quiltHeight);
                        EditorGUILayout.LabelField("View Size: ", qs.viewWidth + " x " + qs.viewHeight);
                        EditorGUILayout.LabelField("Tiling: ", qs.viewColumns + " x " + qs.viewRows);
                        EditorGUILayout.LabelField("Views Total: ", "" + qs.numViews);
                        continue;
                    }

                    // don't let quiltRT be editable
                    if (prop.name == "quiltRT")
                    {
                        GUI.enabled = false;
                        EditorGUILayout.PropertyField(prop, true);
                        GUI.enabled = true;
                        continue;
                    }

                    // target display
                    if (prop.name == "targetDisplay")
                    {
                        DisplayTarget dt = (DisplayTarget)hp.targetDisplay;
                        EditorGUI.BeginChangeCheck();
                        dt = (DisplayTarget)EditorGUILayout.EnumPopup("Target Display", dt);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(hp, "Change Target Display");
                            hp.targetDisplay = (int)dt;
                            Preview.HandlePreview(false);
                        }
                        continue;
                    }

                    // if all's normal, just draw the property like normal
                    EditorGUILayout.PropertyField(prop, true);

                    // after script name, re-enable GUI
                    if (firstProp)
                    {
                        // version
                        EditorGUILayout.LabelField("Version", Holoplay.version.ToString() + Holoplay.versionLabel, EditorStyles.miniLabel);
                        // re-enable gui and continue
                        GUI.enabled = true;
                        firstProp   = false;
                    }
                }while (prop.NextVisible(false));
            }
            // because it's the last section and doesn't get closed out automatically, force this section to end
            optimization.ForceEnd();

            serializedObject.ApplyModifiedProperties();

            // toggle preview button
            if (GUILayout.Button(Preview.togglePreviewShortcut))
            {
                Preview.HandlePreview();
            }
            // reload calibration button
            if (GUILayout.Button("Reload Calibration"))
            {
                hp.ReloadCalibration();
                int    calibrationCount = Plugin.CalibrationCount();
                string logStr           = calibrationCount == 0 ?
                                          "[HoloPlay] No calibration found" :
                                          string.Format("[HoloPlay] Calibration reloaded! Found {0} calibrations", calibrationCount);
                Debug.Log(logStr);
            }
            // version
            // var versionStyle = new GUIStyle(EditorStyles.miniLabel);
            // EditorGUILayout.LabelField("Version", Holoplay.Version.AsString, versionStyle);
        }