コード例 #1
0
ファイル: UIShotManager.cs プロジェクト: ubisoft/vrtist
        public void OnSetCamera(Shot shot)
        {
            ShotManager           sm        = ShotManager.Instance;
            int                   shotIndex = sm.GetShotIndex(shot);
            ShotManagerActionInfo oldInfo   = new ShotManagerActionInfo
            {
                action    = ShotManagerAction.UpdateShot,
                shotIndex = shotIndex,
                camera    = shot.camera,
            };

            ShotManagerActionInfo info = oldInfo.Copy();

            info.camera = CameraManager.Instance.ActiveCamera;

            new CommandShotManager(oldInfo, info).Submit();

            // Update Camera UI Button
            ShotItem uiItem = GetShotItem(shotIndex);

            if (null != info.camera)
            {
                uiItem.cameraNameLabel.Text = info.camera.name;
            }
            else
            {
                uiItem.cameraNameLabel.Text = "";
            }
        }
コード例 #2
0
ファイル: UIShotManager.cs プロジェクト: ubisoft/vrtist
        public void OnUpdateShotEnd(Shot shot, float value)
        {
            ShotManager sm = ShotManager.Instance;

            int intValue   = Mathf.FloorToInt(value);
            int startValue = shot.start;

            if (intValue < startValue)
            {
                intValue = startValue;
            }

            // Send network message
            ShotManagerActionInfo oldInfo = new ShotManagerActionInfo
            {
                action    = ShotManagerAction.UpdateShot,
                shotIndex = sm.GetShotIndex(shot),
                shotEnd   = shot.end,
            };

            ShotManagerActionInfo info = oldInfo.Copy();

            info.shotEnd = intValue;
            shot.end     = intValue;

            new CommandShotManager(oldInfo, info).Submit();

            UpdateShotItemsColors(GlobalState.Animation.CurrentFrame);
        }
コード例 #3
0
ファイル: UIShotManager.cs プロジェクト: ubisoft/vrtist
        // Update data: move shot
        public void OnMoveShot(int offset)
        {
            ShotManager sm = ShotManager.Instance;

            int shotIndex = shotList.CurrentIndex;

            if (offset < 0 && shotIndex <= 0)
            {
                return;
            }
            if (offset > 0 && shotIndex >= (sm.shots.Count - 1))
            {
                return;
            }

            // Send network message
            ShotManagerActionInfo info = new ShotManagerActionInfo
            {
                action     = ShotManagerAction.MoveShot,
                shotIndex  = shotIndex,
                moveOffset = offset
            };

            new CommandShotManager(info).Submit();
            shotList.CurrentIndex = shotIndex + offset;
            // Rebuild UI
            OnShotManagerChanged();
        }
コード例 #4
0
ファイル: UIShotManager.cs プロジェクト: ubisoft/vrtist
        // Update data: delete shot
        public void OnDeleteShot()
        {
            ShotManager sm = ShotManager.Instance;

            if (shotList.CurrentIndex == -1)
            {
                return;
            }

            // Delete the current shot
            int  shotIndex = shotList.CurrentIndex;
            Shot shot      = sm.shots[shotIndex];

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

            new CommandShotManager(info).Submit();
            // Rebuild UI
            OnShotManagerChanged();
        }
コード例 #5
0
ファイル: UIShotManager.cs プロジェクト: ubisoft/vrtist
        // 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();
        }
コード例 #6
0
ファイル: UIShotManager.cs プロジェクト: ubisoft/vrtist
        public void UpdateShotItemsColors(int currentFrame)
        {
            ShotManager sm = ShotManager.Instance;

            Color focusColor = UIOptions.FocusColor;

            for (int i = 0; i < sm.shots.Count; ++i)
            {
                ShotItem item                 = GetShotItem(i);
                Shot     shot                 = sm.shots[i];
                Color    defaultColor         = UIOptions.BackgroundColor;
                Color    defaultSelectedColor = UIOptions.SelectedColor;

                if (currentFrame == shot.start)
                {
                    SetUIElementColors(item.startFrameSpinner, focusColor, focusColor);
                }
                else
                {
                    SetUIElementColors(item.startFrameSpinner, defaultColor, defaultSelectedColor);
                }

                if (currentFrame == shot.end)
                {
                    SetUIElementColors(item.endFrameSpinner, focusColor, focusColor);
                }
                else
                {
                    SetUIElementColors(item.endFrameSpinner, defaultColor, defaultSelectedColor);
                }

                if (shot.end <= shot.start)
                {
                    SetUIElementColors(item.frameRangeLabel, defaultColor, UIOptions.ErrorColor);
                }
                else
                {
                    if (currentFrame > shot.start && currentFrame < shot.end)
                    {
                        SetUIElementColors(item.frameRangeLabel, focusColor, focusColor);
                    }
                    else
                    {
                        SetUIElementColors(item.frameRangeLabel, defaultColor, defaultSelectedColor);
                    }
                }
            }
        }
コード例 #7
0
ファイル: UIShotManager.cs プロジェクト: ubisoft/vrtist
        public void OnUpdateShotColor(Shot shot, Color value)
        {
            ShotManager sm = ShotManager.Instance;

            // Send network message
            ShotManagerActionInfo oldInfo = new ShotManagerActionInfo
            {
                action    = ShotManagerAction.UpdateShot,
                shotIndex = sm.GetShotIndex(shot),
                shotColor = shot.color
            };

            ShotManagerActionInfo info = oldInfo.Copy();

            info.shotColor = value;
            shot.color     = value;

            new CommandShotManager(oldInfo, info).Submit();
        }
コード例 #8
0
ファイル: UIShotManager.cs プロジェクト: ubisoft/vrtist
        public void OnUpdateShotName(Shot shot, string value)
        {
            ShotManager sm = ShotManager.Instance;

            // Send network message
            ShotManagerActionInfo oldInfo = new ShotManagerActionInfo
            {
                action    = ShotManagerAction.UpdateShot,
                shotIndex = sm.GetShotIndex(shot),
                shotName  = shot.name
            };

            ShotManagerActionInfo info = oldInfo.Copy();

            info.shotName = value;
            shot.name     = value;

            new CommandShotManager(oldInfo, info).Submit();
            OnShotManagerChanged();
        }
コード例 #9
0
ファイル: UIShotManager.cs プロジェクト: ubisoft/vrtist
        public void OnUpdateShotEnabled(Shot shot, bool value)
        {
            Assert.IsTrue(ShotManager.Instance.ActiveShotIndex >= 0); // TODO: voir si le probleme persiste une fois que le rayon fonctionne.

            ShotManager sm = ShotManager.Instance;

            // Send network message
            ShotManagerActionInfo oldInfo = new ShotManagerActionInfo
            {
                action      = ShotManagerAction.UpdateShot,
                shotIndex   = sm.GetShotIndex(shot),
                shotEnabled = shot.enabled ? 1 : 0
            };

            ShotManagerActionInfo info = oldInfo.Copy();

            info.shotEnabled = value ? 1 : 0;
            shot.enabled     = value;

            new CommandShotManager(oldInfo, info).Submit();
        }
コード例 #10
0
ファイル: UIShotManager.cs プロジェクト: ubisoft/vrtist
        // 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();
        }
コード例 #11
0
ファイル: UIShotManager.cs プロジェクト: ubisoft/vrtist
        // Update UI: rebuild shots list
        void OnShotManagerChanged()
        {
            shotList.Clear();
            ShotManager sm = ShotManager.Instance;
            int         activeShotCount = 0;

            foreach (Shot shot in sm.shots)
            {
                ShotItem shotItem = ShotItem.GenerateShotItem(shot);
                shotItem.AddListeners(OnUpdateShotName, OnUpdateShotStart, OnUpdateShotEnd, OnUpdateShotColor, OnUpdateShotEnabled, OnSetCamera);
                UIDynamicListItem dlItem = shotList.AddItem(shotItem.transform);
                dlItem.UseColliderForUI       = false;       // dont use the default global collider, sub-widget will catch UI events and propagate them.
                shotItem.transform.localScale = Vector3.one; // Items are hidden (scale 0) while they are not added into a list, so activate the item here.
                shotItem.SetListItem(dlItem);                // link individual elements to their parent list in order to be able to send messages upwards.

                if (shot.enabled)
                {
                    activeShotCount++;
                }
            }
            shotList.CurrentIndex     = sm.ActiveShotIndex;
            activeShotCountLabel.Text = activeShotCount.ToString() + "/" + sm.shots.Count.ToString();
        }