Exemplo n.º 1
0
        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 = "";
            }
        }
Exemplo n.º 2
0
        // Update UI: set current shot
        void OnActiveShotChanged()
        {
            int itemIndex        = 0;
            int currentShotIndex = ShotManager.Instance.ActiveShotIndex;

            foreach (UIDynamicListItem item in shotList.GetItems())
            {
                ShotItem shotItem = item.Content.GetComponent <ShotItem>();
                shotItem.currentShotLabel.Selected = (itemIndex++ == currentShotIndex);
            }
        }
Exemplo n.º 3
0
        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);
                    }
                }
            }
        }
Exemplo n.º 4
0
        // 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();
        }
Exemplo n.º 5
0
        public static ShotItem GenerateShotItem(Shot shot)
        {
            GameObject root     = new GameObject("shotItem");
            ShotItem   shotItem = root.AddComponent <ShotItem>();

            root.layer = LayerMask.NameToLayer("CameraHidden");

            // Set the item invisible in order to hide it while it is not added into
            // a list. We will activate it after it is added
            root.transform.localScale = Vector3.zero;

            float cx = 0.0f;

            //
            // ACTIVE CAMERA Button
            //
            UILabel currentShotLabel = UILabel.Create(new UILabel.CreateLabelParams
            {
                parent           = root.transform,
                widgetName       = "CurrentShotLabel",
                relativeLocation = new Vector3(0, 0, -UIButton.default_thickness),
                width            = 0.01f,
                height           = 0.03f,
                margin           = 0.001f,
                material         = UIUtils.LoadMaterial("UIBase"),
                selectedColor    = UIOptions.FocusColorVar,
                caption          = "",
            });

            currentShotLabel.SetLightLayer(3);

            cx += 0.01f;

            //
            // ENABLE Checkbox
            //
            UICheckbox shotEnabledCheckbox = UICheckbox.Create(new UICheckbox.CreateParams
            {
                parent           = root.transform,
                widgetName       = "ShotEnabledCheckbox",
                relativeLocation = new Vector3(cx, 0, -UICheckbox.default_thickness),
                width            = 0.03f,
                height           = 0.03f,
                content          = UICheckbox.CheckboxContent.CheckboxOnly,
                margin           = 0.001f,
                material         = UIUtils.LoadMaterial("UIBase"),
            });

            shotEnabledCheckbox.SetLightLayer(3);

            cx += 0.03f;

            //
            // SHOT NAME Label
            //
            UILabel shotNameLabel = UILabel.Create(new UILabel.CreateLabelParams
            {
                parent           = root.transform,
                widgetName       = "ShotNameLabel",
                relativeLocation = new Vector3(cx, 0, -UIButton.default_thickness),
                width            = 0.15f,
                height           = 0.020f,
                margin           = 0.001f,
                material         = UIUtils.LoadMaterial("UIBase"),
            });

            shotNameLabel.SetLightLayer(3);
            UIUtils.SetTMProStyle(shotNameLabel.gameObject);

            //
            // CAMERA NAME Label
            //
            UILabel cameraNameLabel = UILabel.Create(new UILabel.CreateLabelParams
            {
                parent           = root.transform,
                widgetName       = "CameraNameLabel",
                relativeLocation = new Vector3(cx, -0.020f, -UIButton.default_thickness),
                width            = 0.15f,
                height           = 0.01f,
                margin           = 0.001f,
                fgcolor          = UIOptions.Instance.attenuatedTextColor,
                material         = UIUtils.LoadMaterial("UIBase"),
            });

            cameraNameLabel.SetLightLayer(3);
            UIUtils.SetTMProStyle(cameraNameLabel.gameObject, alignment: TextAlignmentOptions.BottomRight);

            cx += 0.15f;

            // Start frame button
            UIButton startFrameButton = UIButton.Create(new UIButton.CreateButtonParams
            {
                parent           = root.transform,
                widgetName       = "StartFrameButton",
                relativeLocation = new Vector3(cx, 0, -UIButton.default_thickness),
                width            = 0.02f,
                height           = 0.03f,
                icon             = UIUtils.LoadIcon("next"),
                buttonContent    = UIButton.ButtonContent.ImageOnly,
                margin           = 0.001f,
            });

            startFrameButton.SetLightLayer(3);

            cx += 0.02f;

            // START: Add UISpinner
            UISpinner startFrameSpinner = UISpinner.Create(new UISpinner.CreateArgs
            {
                parent                 = root.transform,
                widgetName             = "StartFrame",
                relativeLocation       = new Vector3(cx, 0, -UISpinner.default_thickness),
                width                  = 0.055f,
                height                 = 0.03f,
                visibility_type        = UISpinner.TextAndValueVisibilityType.ShowValueOnly,
                value_type             = UISpinner.SpinnerValueType.Int,
                min_spinner_value      = 0,
                max_spinner_value      = 10000,
                cur_spinner_value      = shot.start,
                spinner_value_rate     = 30,
                spinner_value_rate_ray = 30,
                margin                 = 0.001f,
            });

            startFrameSpinner.baseColor.useConstant     = true;
            startFrameSpinner.baseColor.constant        = UIOptions.BackgroundColor;
            startFrameSpinner.selectedColor.useConstant = true;
            startFrameSpinner.selectedColor.constant    = UIOptions.SelectedColor;
            startFrameSpinner.SetLightLayer(3);
            UIUtils.SetTMProStyle(startFrameSpinner.gameObject);

            cx += 0.055f;

            // END: Add UISpinner
            UISpinner endFrameSpinner = UISpinner.Create(new UISpinner.CreateArgs
            {
                parent                 = root.transform,
                widgetName             = "EndFrame",
                relativeLocation       = new Vector3(cx, 0, -UISpinner.default_thickness),
                width                  = 0.055f,
                height                 = 0.03f,
                visibility_type        = UISpinner.TextAndValueVisibilityType.ShowValueOnly,
                value_type             = UISpinner.SpinnerValueType.Int,
                min_spinner_value      = 0,
                max_spinner_value      = 10000,
                cur_spinner_value      = shot.end,
                spinner_value_rate     = 30,
                spinner_value_rate_ray = 30,
                margin                 = 0.001f,
            });

            endFrameSpinner.baseColor.useConstant     = true;
            endFrameSpinner.baseColor.constant        = UIOptions.BackgroundColor;
            endFrameSpinner.selectedColor.useConstant = true;
            endFrameSpinner.selectedColor.constant    = UIOptions.SelectedColor;
            endFrameSpinner.SetLightLayer(3);
            UIUtils.SetTMProStyle(endFrameSpinner.gameObject);

            cx += 0.055f;

            // End frame button
            UIButton endFrameButton = UIButton.Create(new UIButton.CreateButtonParams
            {
                parent           = root.transform,
                widgetName       = "EndFrameButton",
                relativeLocation = new Vector3(cx, 0, -UIButton.default_thickness),
                width            = 0.02f,
                height           = 0.03f,
                icon             = UIUtils.LoadIcon("prev"),
                buttonContent    = UIButton.ButtonContent.ImageOnly,
                margin           = 0.001f,
            });

            endFrameButton.SetLightLayer(3);

            cx += 0.02f;

            // RANGE: Add UILabel
            UILabel frameRangeLabel = UILabel.Create(new UILabel.CreateLabelParams
            {
                parent           = root.transform,
                widgetName       = "FrameRange",
                relativeLocation = new Vector3(cx, 0, -UILabel.default_thickness),
                width            = 0.04f,
                height           = 0.03f,
                margin           = 0.001f,
                material         = UIUtils.LoadMaterial("UIBase"),
            });

            frameRangeLabel.baseColor.useConstant     = true;
            frameRangeLabel.baseColor.constant        = UIOptions.BackgroundColor;
            frameRangeLabel.selectedColor.useConstant = true;
            frameRangeLabel.selectedColor.constant    = UIOptions.SelectedColor;
            frameRangeLabel.SetLightLayer(3);
            UIUtils.SetTMProStyle(frameRangeLabel.gameObject, alignment: TextAlignmentOptions.Center);
            cx += 0.04f;

            // Set camera
            UIButton setCameraButton = UIButton.Create(new UIButton.CreateButtonParams
            {
                parent           = root.transform,
                widgetName       = "SetCameraButton",
                relativeLocation = new Vector3(cx, 0, -UIButton.default_thickness),
                width            = 0.03f,
                height           = 0.03f,
                icon             = UIUtils.LoadIcon("icon-camera"),
                buttonContent    = UIButton.ButtonContent.ImageOnly,
                margin           = 0.001f,
            });

            setCameraButton.isCheckable              = true;
            setCameraButton.checkedSprite            = UIUtils.LoadIcon("icon-camera");
            setCameraButton.checkedColor.useConstant = false;
            setCameraButton.checkedColor.constant    = UIOptions.FocusColor;
            setCameraButton.checkedColor.reference   = UIOptions.FocusColorVar;
            setCameraButton.baseSprite = UIUtils.LoadIcon("icon-camera");
            setCameraButton.SetLightLayer(3);

            // Link widgets to the item script.
            shotItem.currentShotLabel    = currentShotLabel;
            shotItem.shotEnabledCheckbox = shotEnabledCheckbox;
            shotItem.shotNameLabel       = shotNameLabel;
            shotItem.cameraNameLabel     = cameraNameLabel;
            shotItem.startFrameSpinner   = startFrameSpinner;
            shotItem.startFrameButton    = startFrameButton;
            shotItem.frameRangeLabel     = frameRangeLabel;
            shotItem.endFrameSpinner     = endFrameSpinner;
            shotItem.endFrameButton      = endFrameButton;
            shotItem.setCameraButton     = setCameraButton;

            shotItem.SetShot(shot);

            return(shotItem);
        }