Пример #1
0
        public static ShotObject InitializeStorage()
        {
            var guids = AssetDatabase.FindAssets("t: ShotObject");

            if (guids.Length > 0)
            {
                string     p   = AssetDatabase.GUIDToAssetPath(guids[0]);
                ShotObject obj = AssetDatabase.LoadAssetAtPath(p, typeof(ShotObject)) as ShotObject;

                if (obj != null)
                {
                    return(obj);
                }
            }

            ShotObject asset = CreateInstance <ShotObject>();

            asset.Init();

            string path = "Assets/Shot Storage.asset";

            AssetDatabase.CreateAsset(asset, path);

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            return(asset);
        }
Пример #2
0
        public static void PreWarm(ShotObject shotObj)
        {
            if (shotObj == null || shotObj.shots.Count <= 0)
            {
                return;
            }

            var shots = shotObj.shots;

            for (int i = shots.Count - 1; i >= 0; i--)
            {
                ShotManager.ApplyShot(shots[i], shotObj);

                var selections = shots[i].selectedObjs;
                for (int j = selections.Count - 1; j >= 0; j--)
                {
                    ShotManager.ApplySelection(selections[j].SelectedObj);
                }
            }
        }
Пример #3
0
        void OnGUI()
        {
            if (Storage != null)
            {
                RenderShotInspector();
            }

            GUILayout.BeginHorizontal();
            Storage = (ShotObject)EditorGUILayout.ObjectField(Storage, typeof(ShotObject), allowSceneObjects: false);
            if (GUILayout.Button("PreWarm", GUILayout.Width(70)))
            {
                ShotManager.PreWarm(Storage);
            }
            GUILayout.EndHorizontal();

            if (Storage != null)
            {
                EditorUtility.SetDirty(Storage);
            }
        }
Пример #4
0
        void OnGUI()
        {
            if (Storage != null)
            {
                RenderShotInspector();

                //Render new shot buttons
                GUILayout.BeginHorizontal();

                if (GUILayout.Button("New Shot"))
                {
                    Storage.shots.Add(new Shot("New Shot"));
                }

                if (GUILayout.Button("Capture Shot"))
                {
                    Shot shot = new Shot("New Shot");
                    RecordSceneCamera(shot);
                    RecordSelection(shot);
                    RecordTimeStamp(shot);
                    Storage.shots.Add(shot);
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            Storage = (ShotObject)EditorGUILayout.ObjectField(Storage, typeof(ShotObject), allowSceneObjects: false);

            if (GUILayout.Button("PreWarm", GUILayout.Width(70)))
            {
                ShotManager.PreWarm(Storage);
            }
            GUILayout.EndHorizontal();

            if (Storage != null)
            {
                EditorUtility.SetDirty(Storage);
            }
        }
Пример #5
0
        public static void ApplyShot(Shot shot, ShotObject shotObj)
        {
            SceneView.lastActiveSceneView.pivot    = shot.position;
            SceneView.lastActiveSceneView.rotation = shot.rotation;
            SceneView.lastActiveSceneView.size     = shot.size;
            SceneView.lastActiveSceneView.Repaint();

            if (shot.selectedObjs.Count > 0)
            {
                ShotManager.ApplySelection(shot.selectedObjs[0].SelectedObj);
            }
            else
            {
                ShotManager.ApplySelection(null);
            }

            if (shotObj != null && shotObj.Director != null)
            {
                shotObj.Director.time = shot.playableTimestamp;
                shotObj.Director.Evaluate();
            }
        }