public static EditorWindow InitWindow(Plot plot)
        {
            PlotEditorWindow window = GetWindow <PlotEditorWindow>(true, "Plot Editor");

            window.m_plot       = plot;
            window.m_plotEditor = (PlotEditor)Editor.CreateEditor(plot);
            window.m_plotEditor.isEditorWindow = true;
            return(window);
        }
        public void OnInspectorGUI()
        {
            Rect targetRect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);

            using (new EditorGUI.DisabledScope(true))
            {
                EditorGUI.ObjectField(targetRect, m_plot, typeof(Plot), false);
            }
            Rect buttonRect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight * 12);

            if (GUI.Button(buttonRect, "Open Editor"))
            {
                PlotEditorWindow.InitWindow(m_plot);
            }
        }
Пример #3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            Plot plot = (Plot)property.objectReferenceValue;

            if (plot == null)
            {
                EditorGUI.PropertyField(position, property, label);
            }
            else
            {
                Rect propertyRect = new Rect(position.x, position.y, position.width - 105, position.height);
                Rect buttonRect   = new Rect(position.xMax - 100, position.y, 100, position.height);
                EditorGUI.PropertyField(propertyRect, property, label);
                if (GUI.Button(buttonRect, "Open Editor", EditorStyles.miniButton))
                {
                    EditorWindow editorWindow = PlotEditorWindow.InitWindow(plot);
                    editorWindow.Show();
                }
            }

            EditorGUI.EndProperty();
        }