void OnEnable() { userNodeFolder = EditorPrefs.GetString(UserNodeFolderKey, ""); if (userNodeFolder == "") { userNodeFolder = DefaultNodeFolder; } if (window != null) { // no need to reconstruct everything return; } window = GetWindow <OhBehaveEditorWindow>(); window.titleContent = new GUIContent("OhBehave!"); try { if (EditorStyles.helpBox == null) { //EditorStyle not yet initialized return; } } catch (System.Exception) { //EditorStyle not yet initialized return; } CreateStyles(); if (zoomer == null) { zoomer = new EditorZoomer(); } if (treeBlueprint != null) { treeBlueprint.ConstructNodes(); zoomer.Reset(treeBlueprint.zoomerSettings); } }
void OnGUI() { if (InPointStyle == null) { CreateStyles(); } { // Just keeping this around for future reference. if (NodeEditPopup.instance != null) { if (Event.current.type == EventType.MouseDown && EditorWindow.mouseOverWindow != NodeEditPopup.instance) { NodeEditPopup.instance.Hide(); } } } if (treeBlueprint == null) { return; } if (zoomer == null) { zoomer = new EditorZoomer(); zoomer.Reset(treeBlueprint.zoomerSettings); } zoomer.HandleEvents(Event.current); DrawHorizontalUILine(Color.gray); Rect lastRect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.Repaint) { zoomRect.position = new Vector2( ZOOM_BORDER, lastRect.yMax + lastRect.height + ZOOM_BORDER); zoomRect.size = new Vector2( window.position.width - ZOOM_BORDER * 2, window.position.height - (lastRect.yMax + ZOOM_BORDER * 2 + AREA_BELOW_ZOOM_HEIGHT)); } zoomer.Begin(zoomRect); { treeBlueprint.OnGui(Event.current, zoomer); } zoomer.End(new Rect( 0, zoomRect.yMax + zoomRect.position.y - 50, window.position.width, window.position.height)); treeBlueprint.childrenMoveWithParent = EditorGUILayout.ToggleLeft("Reposition children with Parent", treeBlueprint.childrenMoveWithParent); EditorGUILayout.Vector2Field("mouse", Event.current.mousePosition); if (GUI.changed) { Repaint(); } }