private void OnEnable() { //Check for target if (target == null) { return; } //Get our manager m_capture = (PegasusCapture)target; //Set up the default camera if we can if (m_capture.m_mainCamera == null) { if (Camera.main != null) { m_capture.m_mainCamera = Camera.main; EditorUtility.SetDirty(m_capture); } } //Set up the capturer object if (!Application.isPlaying) { if (m_capture.m_path == null) { m_capture.m_path = PegasusPath.CreatePegasusPath(); } //And add Pegasus to the environment SetPegasusDefines(); //Update the reticules text if we have it m_capture.UpdateReticuleText(); //And visibility m_capture.UpdateReticuleVisibility(); } }
public static void AddPegasusCaptureToScene(MenuCommand menuCommand) { GameObject pegasusCaptureGo = GameObject.Find("Pegasus Capture"); if (pegasusCaptureGo != null) { Debug.Log("Pegasus capture is already in the scene."); return; } //Create pegasus capture pegasusCaptureGo = new GameObject("Pegasus Capture"); PegasusCapture pegasusCapture = pegasusCaptureGo.AddComponent <PegasusCapture>(); // Ensure it gets reparented if this was a context click (otherwise does nothing) GameObjectUtility.SetParentAndAlign(pegasusCaptureGo, menuCommand.context as GameObject); // Register the creation in the undo system Undo.RegisterCreatedObjectUndo(pegasusCaptureGo, "Created " + pegasusCaptureGo.name); Selection.activeObject = pegasusCaptureGo; //Create the reticule GameObject goReticule = GameObject.Find("Pegasus Capture Reticule"); if (goReticule == null) { GameObject goReticulePrefab = GetAssetPrefab("Pegasus Capture Reticule"); if (goReticulePrefab != null) { goReticule = GameObject.Instantiate(goReticulePrefab); goReticule.name = "Pegasus Capture Reticule"; } } //Assign it to the capture pegasusCapture.m_reticuleGO = goReticule; }
public override void OnInspectorGUI() { //Get our manager m_capture = (PegasusCapture)target; //Set up the box style if (m_boxStyle == null) { m_boxStyle = new GUIStyle(GUI.skin.box); m_boxStyle.normal.textColor = GUI.skin.label.normal.textColor; m_boxStyle.fontStyle = FontStyle.Bold; m_boxStyle.alignment = TextAnchor.UpperLeft; } //Setup the wrap style if (m_wrapStyle == null) { m_wrapStyle = new GUIStyle(GUI.skin.label); m_wrapStyle.fontStyle = FontStyle.Normal; m_wrapStyle.wordWrap = true; } //Text intro GUILayout.BeginVertical(string.Format("Pegasus ({0}.{1})", PegasusConstants.MajorVersion, PegasusConstants.MinorVersion), m_boxStyle); GUILayout.Space(20); EditorGUILayout.LabelField("Welcome to Pegasus Capture!\nPress Play and then your selected hot key to capture POI for your flythrough. Then press Create Pegasus to create a Pegasus fly through after you have finshed.\nNOTE: You can adjust the rotation & position damping on the Pegasus you create to make your play back more accurate.", m_wrapStyle); GUILayout.EndVertical(); EditorGUI.BeginChangeCheck(); GUILayout.Space(5); KeyCode keyCodeCapture = (KeyCode)EditorGUILayout.EnumPopup(GetLabel("Capture Key"), m_capture.m_keyCodeCapture); Camera mainCamera = (Camera)EditorGUILayout.ObjectField(GetLabel("Target Camera"), m_capture.m_mainCamera, typeof(Camera), true); PegasusPath path = (PegasusPath)EditorGUILayout.ObjectField(GetLabel("Pegasus Path"), m_capture.m_path, typeof(PegasusPath), false); bool enableOnStart = EditorGUILayout.Toggle(GetLabel("Enable On Start"), m_capture.m_enableOnStart); bool clearOnStart = EditorGUILayout.Toggle(GetLabel("Clear On Start"), m_capture.m_clearOnStart); bool showReticule = EditorGUILayout.Toggle(GetLabel("Show Reticule"), m_capture.m_showReticule); if (path == null || path.m_path.Count == 0) { GUI.enabled = false; } if (DisplayButton(GetLabel("Create Pegasus"))) { path.CreatePegasusFromPath(); enableOnStart = false; } GUI.enabled = true; GUILayout.Space(5f); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(m_capture, "Made changes"); m_capture.m_mainCamera = mainCamera; m_capture.m_path = path; m_capture.m_clearOnStart = clearOnStart; ; if (m_capture.m_keyCodeCapture != keyCodeCapture) { m_capture.m_keyCodeCapture = keyCodeCapture; m_capture.UpdateReticuleText(); } if (m_capture.m_showReticule != showReticule || m_capture.m_enableOnStart != enableOnStart) { m_capture.m_enableOnStart = enableOnStart; m_capture.m_showReticule = showReticule; m_capture.UpdateReticuleVisibility(); } EditorUtility.SetDirty(m_capture); } }