예제 #1
0
        // Update data: add a shot
        public void OnAddShot()
        {
            ShotManager sm = ShotManager.Instance;

            // Take the current shot to find the start frame of the new shot
            // Keep same camera as the current shot if anyone
            int        start = GlobalState.Animation.CurrentFrame;
            GameObject camera;

            if (shotList.CurrentIndex != -1)
            {
                Shot selectedShot = sm.shots[shotList.CurrentIndex];
                start  = selectedShot.end + 1;
                camera = CameraManager.Instance.ActiveCamera != null ? CameraManager.Instance.ActiveCamera : selectedShot.camera;
            }
            else
            {
                camera = CameraManager.Instance.ActiveCamera;
            }
            int end = start + 50;  // arbitrary duration

            end = Mathf.Min(end, GlobalState.Animation.EndFrame);

            // Look at all the shots to find a name for the new shot
            string name = sm.GetUniqueShotName();

            Shot shot = new Shot {
                name = name, camera = camera, enabled = true, end = end, start = start
            };
            int shotIndex = shotList.CurrentIndex;

            // Send network message
            ShotManagerActionInfo info = new ShotManagerActionInfo
            {
                action      = ShotManagerAction.AddShot,
                camera      = camera,
                shotIndex   = shotIndex,
                shotName    = shot.name,
                shotStart   = start,
                shotEnd     = end,
                shotEnabled = 1,
                shotColor   = Color.blue // TODO: find a unique color
            };

            new CommandShotManager(info).Submit();
            // Add the shot to ShotManager singleton
            shotIndex++;
            sm.SetCurrentShotIndex(shotIndex);

            // Rebuild UI
            OnShotManagerChanged();
        }
예제 #2
0
        // Duplicate Shot
        public void OnDuplicateShot()
        {
            ShotManager sm = ShotManager.Instance;

            // Take the current shot to find the start frame of the new shot
            // Keep same camera as the current shot if anyone
            if (shotList.CurrentIndex == -1)
            {
                return;
            }

            Shot shot = sm.shots[shotList.CurrentIndex].Copy();

            shot.name = sm.GetUniqueShotName();
            int shotIndex = shotList.CurrentIndex;

            // Send network message
            ShotManagerActionInfo info = new ShotManagerActionInfo
            {
                action      = ShotManagerAction.AddShot,
                camera      = shot.camera,
                shotIndex   = shotIndex,
                shotName    = shot.name,
                shotStart   = shot.start,
                shotEnd     = shot.end,
                shotEnabled = shot.enabled ? 1 : 0,
                shotColor   = Color.blue // TODO: find a unique color
            };

            new CommandShotManager(info).Submit();

            // Add the shot to ShotManager singleton
            shotIndex++;
            sm.SetCurrentShotIndex(shotIndex);

            // Rebuild UI
            OnShotManagerChanged();
        }