Example #1
0
        /// <summary>
        /// Create a new pegasus path
        /// </summary>
        /// <returns>New pegasus path</returns>
        public static PegasusPath CreatePegasusPath()
        {
            PegasusPath pp = ScriptableObject.CreateInstance <PegasusPath>();

            #if UNITY_EDITOR
            string path = "Assets/PegasusPath.asset";
            AssetDatabase.CreateAsset(pp, path);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            #endif
            return(pp);
        }
        void Start()
        {
            //Grab main camera if necessary
            if (m_mainCamera == null)
            {
                m_mainCamera = Camera.main;
            }

            //Create new path if necessary
            if (m_path == null)
            {
                m_path = PegasusPath.CreatePegasusPath();
            }

            //Show reticule
            if (m_reticuleGO == null)
            {
                m_reticuleGO = GameObject.Find("Pegasus Capture Reticule");
            }
            if (m_reticuleGO != null)
            {
                m_reticuleGO.SetActive(m_showReticule && m_enableOnStart);
                UpdateReticuleText();
            }

            //Show previous path
            if (m_enableOnStart)
            {
                //Clear path
                if (m_clearOnStart)
                {
                    m_path.ClearPath();
                }

                //Display path
                foreach (var path in m_path.m_path)
                {
                    GameObject marker = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                    marker.transform.position   = path.m_location;
                    marker.transform.localScale = Vector3.one * 0.25f;
                }
            }
        }
Example #3
0
        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();
            }
        }
Example #4
0
        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);
            }
        }