void OnGUI()
{
if (!_instance) return;
// Check if window was open on recompile. If so, we need to reinitialize
if (mStyleHeaderStyle == null) {
mStyleHeaderStyle = new GUIStyle(GUI.skin.GetStyle("button"));
mStyleHeaderStyle.fontStyle = FontStyle.Bold;
mStyleBoldCentered = new GUIStyle(GUI.skin.GetStyle("label"));
mStyleBoldCentered.fontStyle = FontStyle.Bold;
mStyleBoldCentered.alignment = TextAnchor.MiddleCenter;
mStyleBoldCentered.stretchWidth = true;
mStyleEmptyBox = new GUIStyle(GUI.skin.GetStyle("box"));
mStyleEmptyBox.margin = new RectOffset(0, 0, 0, 0);
mStyleEmptyBox.padding = new RectOffset(0, 0, 0, 0);
}
if (!SelectedParticleSystem) return;
mColDefault = GUI.backgroundColor;
Event e = Event.current;
Object[] deephierarchy=new Object[0];
if ((e.type == EventType.MouseDown && e.button == 0) || (e.type == EventType.KeyUp && (e.keyCode == KeyCode.Tab))) {
deephierarchy=EditorUtility.CollectDeepHierarchy(new Object[]{SelectedObject});
Undo.SetSnapshotTarget(deephierarchy, "Magical Box value change");
Undo.CreateSnapshot();
Undo.ClearSnapshotTarget();
mListeningForGUIChanges = true;
}
// Store mouse position for editor enabled scripts
if (!Application.isPlaying) {
MBEditorEnabledScript.MousePosition = new Vector3(
e.mousePosition.x, -e.mousePosition.y+25, 0);
}
// Top row holds Toolbar
EditorGUILayout.BeginHorizontal();
DoToolbarGUI();
EditorGUILayout.EndHorizontal();
// Left window side shows the overview
GUILayout.BeginArea(new Rect(0, 26, 204, position.height - 26), GUI.skin.GetStyle("Box"));
mOverviewScroll = EditorGUILayout.BeginScrollView(mOverviewScroll);
DoOverviewGUI();
EditorGUILayout.EndScrollView();
GUILayout.EndArea();
// Right window side shows details of selection
GUI.backgroundColor = mColDefault;
GUILayout.BeginArea(new Rect(205, 26, position.width - 205, position.height - 26), GUI.skin.GetStyle("Box"));
if (SelectedObject.Matches(typeof(MBEmitter), typeof(MBParameter)))
DoEmitterGUI();
else if (SelectedObject is MBParticleSystem)
DoSystemGUI();
else if (SelectedObject is MBAnchor)
DoAnchorGUI();
else if (SelectedObject is MBLayer)
DoLayerGUI();
GUILayout.EndArea();
// Control Undo
if (mListeningForGUIChanges && GUI.changed) {
Undo.SetSnapshotTarget(deephierarchy, "Magical Box value change");
Undo.RegisterSnapshot();
Undo.ClearSnapshotTarget();
mListeningForGUIChanges = false;
}
GUI.backgroundColor = mColDefault;
}