Esempio n. 1
0
        private void SetCheckboxValue(Transform checkbox, bool value)
        {
            UICheckbox checkboxComp = checkbox.GetComponent <UICheckbox>();

            if (checkboxComp != null)
            {
                checkboxComp.Checked = value;
            }
        }
Esempio n. 2
0
        public void OnCloseCameraPreview()
        {
            OnCheckShowCameraPreview(false);

            UICheckbox cb = showCameraPreviewCheckbox.GetComponent <UICheckbox>();

            if (cb != null)
            {
                cb.Checked = false;
            }
        }
Esempio n. 3
0
        public void OnCloseShotManager()
        {
            OnCheckShowShotManager(false);

            UICheckbox showShotManager = showShotManagerCheckbox.GetComponent <UICheckbox>();

            if (showShotManager != null)
            {
                showShotManager.Checked = false;
            }
        }
Esempio n. 4
0
        private void OnSceneGUI()
        {
            bool hasUIElementParent = HasUIElemParent();

            UICheckbox uiCheckbox = target as UICheckbox;

            Transform T = uiCheckbox.transform;

            Vector3 posRight   = T.TransformPoint(new Vector3(+uiCheckbox.width, -uiCheckbox.height / 2.0f, 0));
            Vector3 posBottom  = T.TransformPoint(new Vector3(uiCheckbox.width / 2.0f, -uiCheckbox.height, 0));
            Vector3 posAnchor  = T.TransformPoint(uiCheckbox.Anchor);
            float   handleSize = .3f * HandleUtility.GetHandleSize(posAnchor);
            Vector3 snap       = Vector3.one * 0.01f;

            EditorGUI.BeginChangeCheck();

            Handles.color = Handles.xAxisColor;
            Vector3 newTargetPosition_right = Handles.FreeMoveHandle(posRight, Quaternion.identity, handleSize, snap, Handles.SphereHandleCap);

            Handles.color = Handles.yAxisColor;
            Vector3 newTargetPosition_bottom = Handles.FreeMoveHandle(posBottom, Quaternion.identity, handleSize, snap, Handles.SphereHandleCap);

            Handles.color = Handles.zAxisColor;
            //Vector3 newTargetPosition_anchor = hasUIElementParent ? Handles.FreeMoveHandle(posAnchor, Quaternion.identity, handleSize, snap, Handles.SphereHandleCap) : posAnchor;
            Vector3 newTargetPosition_anchor = Handles.FreeMoveHandle(posAnchor, Quaternion.identity, handleSize, snap, Handles.SphereHandleCap);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Change Dimensions");

                Vector3 deltaRight  = newTargetPosition_right - posRight;
                Vector3 deltaBottom = newTargetPosition_bottom - posBottom;
                Vector3 deltaAnchor = newTargetPosition_anchor - posAnchor;

                if (Vector3.SqrMagnitude(deltaRight) > Mathf.Epsilon)
                {
                    uiCheckbox.Width += deltaRight.x;
                }
                else if (Vector3.SqrMagnitude(deltaBottom) > Mathf.Epsilon)
                {
                    uiCheckbox.Height += -deltaBottom.y;
                }
                else if (Vector3.SqrMagnitude(deltaAnchor) > Mathf.Epsilon)
                {
                    Vector3 localDeltaAnchor = T.InverseTransformVector(deltaAnchor);
                    uiCheckbox.RelativeLocation += new Vector3(localDeltaAnchor.x, localDeltaAnchor.y, 0.0f);
                }
            }
        }
Esempio n. 5
0
        public static void OnCreateFromHierarchy()
        {
            Transform parent = null;
            Transform T      = UnityEditor.Selection.activeTransform;

            if (T != null)
            {
                parent = T;
            }

            UICheckbox.Create(new UICheckbox.CreateParams
            {
                parent = parent
            });
        }
Esempio n. 6
0
        void Start()
        {
            ShotManager.Instance.ShotsChangedEvent.AddListener(OnShotManagerChanged);
            ShotManager.Instance.ActiveShotChangedEvent.AddListener(OnActiveShotChanged);
            shotList.ItemClickedEvent += OnListItemClicked;

            montageCheckbox = transform.Find("MainPanel/Montage").GetComponent <UICheckbox>();
            ShotManager.Instance.MontageModeChangedEvent.AddListener(OnMontageModeChanged);

            videoOutputButton          = transform.Find("MainPanel/VideoOutput").GetComponent <UIButton>();
            videoOutputButton.Disabled = !montageCheckbox.Checked;

            GlobalState.Animation.onFrameEvent.AddListener(OnCurrentFrameChanged);
            GlobalState.Animation.onAnimationStateEvent.AddListener(OnAnimationStateChanged);
            ToolsUIManager.Instance.onPaletteOpened.AddListener(OnPaletteOpened);
        }
        public override void Init(Transform rigTransform, Transform worldTransform, Transform leftHandleTransform, Transform rightHandleTransform, Transform pivotTransform, Transform cameraTransform, Transform parametersTransform)
        {
            base.Init(rigTransform, worldTransform, leftHandleTransform, rightHandleTransform, pivotTransform, cameraTransform, parametersTransform);

            // Create tooltips
            Tooltips.SetText(VRDevice.SecondaryController, Tooltips.Location.Joystick, Tooltips.Action.Joystick, "Target / Turn");

            usedControls = UsedControls.LEFT_JOYSTICK;

            Transform teleportParameters = parameters.Find("Teleport");

            teleportParameters.gameObject.SetActive(true);

            UICheckbox lockHeight = teleportParameters.Find("LockHeight").GetComponent <UICheckbox>();

            lockHeight.Checked = options.lockHeight;
        }
Esempio n. 8
0
        public static UICheckbox Create(CreateParams input)
        {
            GameObject go = new GameObject(input.widgetName)
            {
                tag = "UICollider"
            };

            // Find the anchor of the parent if it is a UIElement
            Vector3 parentAnchor = Vector3.zero;

            if (input.parent)
            {
                UIElement elem = input.parent.gameObject.GetComponent <UIElement>();
                if (elem)
                {
                    parentAnchor = elem.Anchor;
                }
            }

            UICheckbox uiCheckbox = go.AddComponent <UICheckbox>(); // NOTE: also creates the MeshFilter, MeshRenderer and Collider components

            uiCheckbox.relativeLocation        = input.relativeLocation;
            uiCheckbox.transform.parent        = input.parent;
            uiCheckbox.transform.localPosition = parentAnchor + input.relativeLocation;
            uiCheckbox.transform.localRotation = Quaternion.identity;
            uiCheckbox.transform.localScale    = Vector3.one;
            uiCheckbox.width                         = input.width;
            uiCheckbox.height                        = input.height;
            uiCheckbox.margin                        = input.margin;
            uiCheckbox.thickness                     = input.thickness;
            uiCheckbox.content                       = input.content;
            uiCheckbox.checkedSprite                 = input.checkedIcon;
            uiCheckbox.uncheckedSprite               = input.uncheckedIcon;
            uiCheckbox.textContent                   = input.caption;
            uiCheckbox.source_material               = input.material;
            uiCheckbox.baseColor.useConstant         = false;
            uiCheckbox.baseColor.reference           = input.color;
            uiCheckbox.textColor.useConstant         = false;
            uiCheckbox.textColor.reference           = input.textColor;
            uiCheckbox.disabledTextColor.useConstant = false;
            uiCheckbox.disabledTextColor.reference   = input.disabledTextColor;
            uiCheckbox.pushedColor.useConstant       = false;
            uiCheckbox.pushedColor.reference         = input.pushedColor;
            uiCheckbox.selectedColor.useConstant     = false;
            uiCheckbox.selectedColor.reference       = input.selectedColor;

            // Setup the Meshfilter
            MeshFilter meshFilter = go.GetComponent <MeshFilter>();

            if (meshFilter != null)
            {
                meshFilter.sharedMesh = UIUtils.BuildRoundedBox(input.width, input.height, input.margin, input.thickness);
                uiCheckbox.Anchor     = Vector3.zero;
                BoxCollider coll = go.GetComponent <BoxCollider>();
                if (coll != null)
                {
                    Vector3 initColliderCenter = meshFilter.sharedMesh.bounds.center;
                    Vector3 initColliderSize   = meshFilter.sharedMesh.bounds.size;
                    if (initColliderSize.z < UIElement.collider_min_depth_shallow)
                    {
                        coll.center = new Vector3(initColliderCenter.x, initColliderCenter.y, UIElement.collider_min_depth_shallow / 2.0f);
                        coll.size   = new Vector3(initColliderSize.x, initColliderSize.y, UIElement.collider_min_depth_shallow);
                    }
                    else
                    {
                        coll.center = initColliderCenter;
                        coll.size   = initColliderSize;
                    }
                    coll.isTrigger = true;
                }
            }

            // Setup the MeshRenderer
            MeshRenderer meshRenderer = go.GetComponent <MeshRenderer>();

            if (meshRenderer != null && uiCheckbox.source_material != null)
            {
                // Clone the material.
                meshRenderer.sharedMaterial     = Instantiate(uiCheckbox.source_material);
                meshRenderer.shadowCastingMode  = UnityEngine.Rendering.ShadowCastingMode.Off;
                meshRenderer.renderingLayerMask = 2; // "LightLayer 1"

                uiCheckbox.SetColor(input.color.value);
            }

            // Add a Canvas
            GameObject canvas = new GameObject("Canvas");

            canvas.transform.parent = uiCheckbox.transform;

            Canvas c = canvas.AddComponent <Canvas>();

            c.renderMode   = RenderMode.WorldSpace;
            c.sortingOrder = 1;

            RectTransform rt = canvas.GetComponent <RectTransform>(); // auto added when adding Canvas

            rt.localScale    = Vector3.one;
            rt.localRotation = Quaternion.identity;
            rt.anchorMin     = new Vector2(0, 1);
            rt.anchorMax     = new Vector2(0, 1);
            rt.pivot         = new Vector2(0, 1); // top left
            rt.sizeDelta     = new Vector2(uiCheckbox.width, uiCheckbox.height);
            rt.localPosition = Vector3.zero;

            CanvasScaler cs = canvas.AddComponent <CanvasScaler>();

            cs.dynamicPixelsPerUnit   = 300; // 300 dpi, sharp font
            cs.referencePixelsPerUnit = 100; // default?

            float minSide = Mathf.Min(uiCheckbox.width, uiCheckbox.height);

            // Add an Image under the Canvas
            if (input.uncheckedIcon != null && input.checkedIcon != null)
            {
                GameObject image = new GameObject("Image");
                image.transform.parent = canvas.transform;

                Image img = image.AddComponent <Image>();
                img.sprite = input.uncheckedIcon;
                img.color  = input.textColor.value;

                RectTransform trt = image.GetComponent <RectTransform>();
                trt.localScale    = Vector3.one;
                trt.localRotation = Quaternion.identity;
                trt.anchorMin     = new Vector2(0, 1);
                trt.anchorMax     = new Vector2(0, 1);
                trt.pivot         = new Vector2(0, 1); // top left
                // TODO: non square icons ratio...
                trt.sizeDelta     = new Vector2(minSide - 2.0f * input.margin, minSide - 2.0f * input.margin);
                trt.localPosition = new Vector3(input.margin, -input.margin, -0.001f);
            }

            // Add a Text under the Canvas
            if (input.content == CheckboxContent.CheckboxAndText)
            {
                GameObject text = new GameObject("Text");
                text.transform.parent = canvas.transform;

                TextMeshProUGUI t = text.AddComponent <TextMeshProUGUI>();
                t.text             = input.caption;
                t.enableAutoSizing = false;
                t.fontSize         = 18;
                t.fontSizeMin      = 1;
                t.fontSizeMin      = 500;
                t.fontStyle        = FontStyles.Normal;
                t.alignment        = TextAlignmentOptions.MidlineLeft;
                t.color            = input.textColor.value;

                RectTransform trt = t.GetComponent <RectTransform>();
                trt.localScale    = 0.01f * Vector3.one;
                trt.localRotation = Quaternion.identity;
                trt.anchorMin     = new Vector2(0, 1);
                trt.anchorMax     = new Vector2(0, 1);
                trt.pivot         = new Vector2(0, 1); // top left

                trt.sizeDelta     = new Vector2((input.width - minSide - input.margin) * 100.0f, (input.height - 2.0f * input.margin) * 100.0f);
                trt.localPosition = new Vector3(minSide, -input.margin, -0.002f);
            }

            UIUtils.SetRecursiveLayer(go, "CameraHidden");

            return(uiCheckbox);
        }
Esempio n. 9
0
        void Start()
        {
            ToggleMouthpiece(mouthpiece, true);

            // Sub panels
            selectPanel    = panel.Find("SelectPanel").gameObject;
            snapPanel      = panel.Find("SnapPanel").gameObject;
            inspectorPanel = panel.Find("ObjectPropertiesPanel").gameObject;

            selectPanel.SetActive(true);
            snapPanel.SetActive(false);
            inspectorPanel.SetActive(false);

            selectPanelButton         = panel.Find("SelectPanelButton").GetComponent <UIButton>();
            selectPanelButton.Checked = true;
            snapPanelButton           = panel.Find("SnapPanelButton").GetComponent <UIButton>();
            inspectorPanelButton      = panel.Find("ObjectPropertiesPanelButton").GetComponent <UIButton>();

            selectPanelButton.onReleaseEvent.AddListener(() => OnSelectPanel(selectPanelButton));
            snapPanelButton.onReleaseEvent.AddListener(() => OnSelectPanel(snapPanelButton));
            inspectorPanelButton.onReleaseEvent.AddListener(() => OnSelectPanel(inspectorPanelButton));

            selectedObjectNameLabel = inspectorPanel.transform.Find("Object Name").GetComponent <UILabel>();

            snapCheckbox         = selectPanel.transform.Find("Snap").GetComponent <UICheckbox>();
            snapToGroundCheckbox = selectPanel.transform.Find("SnapToGround").GetComponent <UICheckbox>();

            // Constraints
            enableParentButton = inspectorPanel.transform.Find("Constraints/Parent/Active Button").GetComponent <UIButton>();
            parentTargetLabel  = inspectorPanel.transform.Find("Constraints/Parent/Target Label").GetComponent <UILabel>();
            selectParentButton = inspectorPanel.transform.Find("Constraints/Parent/Select Button").GetComponent <UIButton>();
            deleteParentButton = inspectorPanel.transform.Find("Constraints/Parent/Delete Button").GetComponent <UIButton>();

            enableParentButton.onReleaseEvent.AddListener(OnToggleParentConstraint);
            deleteParentButton.onReleaseEvent.AddListener(RemoveParentConstraint);

            enableLookAtButton = inspectorPanel.transform.Find("Constraints/Look At/Active Button").GetComponent <UIButton>();
            lookAtTargetLabel  = inspectorPanel.transform.Find("Constraints/Look At/Target Label").GetComponent <UILabel>();
            selectLookAtButton = inspectorPanel.transform.Find("Constraints/Look At/Select Button").GetComponent <UIButton>();
            deleteLookAtButton = inspectorPanel.transform.Find("Constraints/Look At/Delete Button").GetComponent <UIButton>();

            enableLookAtButton.onReleaseEvent.AddListener(OnToggleLookAtConstraint);
            deleteLookAtButton.onReleaseEvent.AddListener(RemoveLookAtConstraint);

            // Transforms
            posXButton = inspectorPanel.transform.Find("Transform/Position/X/Value").GetComponent <UIButton>();
            posYButton = inspectorPanel.transform.Find("Transform/Position/Y/Value").GetComponent <UIButton>();
            posZButton = inspectorPanel.transform.Find("Transform/Position/Z/Value").GetComponent <UIButton>();

            posResetButton = inspectorPanel.transform.Find("Transform/Position/Reset").GetComponent <UIButton>();
            posLockButton  = inspectorPanel.transform.Find("Transform/Position/Global Lock").GetComponent <UIButton>();
            posXLockButton = inspectorPanel.transform.Find("Transform/Position/X/Lock").GetComponent <UIButton>();
            posYLockButton = inspectorPanel.transform.Find("Transform/Position/Y/Lock").GetComponent <UIButton>();
            posZLockButton = inspectorPanel.transform.Find("Transform/Position/Z/Lock").GetComponent <UIButton>();

            rotXButton = inspectorPanel.transform.Find("Transform/Rotation/X/Value").GetComponent <UIButton>();
            rotYButton = inspectorPanel.transform.Find("Transform/Rotation/Y/Value").GetComponent <UIButton>();
            rotZButton = inspectorPanel.transform.Find("Transform/Rotation/Z/Value").GetComponent <UIButton>();

            rotResetButton = inspectorPanel.transform.Find("Transform/Position/Reset").GetComponent <UIButton>();
            rotLockButton  = inspectorPanel.transform.Find("Transform/Rotation/Global Lock").GetComponent <UIButton>();
            rotXLockButton = inspectorPanel.transform.Find("Transform/Rotation/X/Lock").GetComponent <UIButton>();
            rotYLockButton = inspectorPanel.transform.Find("Transform/Rotation/Y/Lock").GetComponent <UIButton>();
            rotZLockButton = inspectorPanel.transform.Find("Transform/Rotation/Z/Lock").GetComponent <UIButton>();

            scaleXButton = inspectorPanel.transform.Find("Transform/Scale/X/Value").GetComponent <UIButton>();
            scaleYButton = inspectorPanel.transform.Find("Transform/Scale/Y/Value").GetComponent <UIButton>();
            scaleZButton = inspectorPanel.transform.Find("Transform/Scale/Z/Value").GetComponent <UIButton>();

            scaleResetButton = inspectorPanel.transform.Find("Transform/Position/Reset").GetComponent <UIButton>();
            scaleLockButton  = inspectorPanel.transform.Find("Transform/Scale/Global Lock").GetComponent <UIButton>();
            scaleXLockButton = inspectorPanel.transform.Find("Transform/Scale/X/Lock").GetComponent <UIButton>();
            scaleYLockButton = inspectorPanel.transform.Find("Transform/Scale/Y/Lock").GetComponent <UIButton>();
            scaleZLockButton = inspectorPanel.transform.Find("Transform/Scale/Z/Lock").GetComponent <UIButton>();

            posXButton.onReleaseEvent.AddListener(() => OnStartEditTransform(posXButton.Text, "px"));
            posYButton.onReleaseEvent.AddListener(() => OnStartEditTransform(posYButton.Text, "py"));
            posZButton.onReleaseEvent.AddListener(() => OnStartEditTransform(posZButton.Text, "pz"));

            rotXButton.onReleaseEvent.AddListener(() => OnStartEditTransform(rotXButton.Text, "rx"));
            rotYButton.onReleaseEvent.AddListener(() => OnStartEditTransform(rotYButton.Text, "ry"));
            rotZButton.onReleaseEvent.AddListener(() => OnStartEditTransform(rotZButton.Text, "rz"));

            scaleXButton.onReleaseEvent.AddListener(() => OnStartEditTransform(scaleXButton.Text, "sx"));
            scaleYButton.onReleaseEvent.AddListener(() => OnStartEditTransform(scaleYButton.Text, "sy"));
            scaleZButton.onReleaseEvent.AddListener(() => OnStartEditTransform(scaleZButton.Text, "sz"));

            posLockButton.onCheckEvent.AddListener(SetLockPosition);
            posXLockButton.onCheckEvent.AddListener((bool value) => SetMoveOnX(!value));
            posYLockButton.onCheckEvent.AddListener((bool value) => SetMoveOnY(!value));
            posZLockButton.onCheckEvent.AddListener((bool value) => SetMoveOnZ(!value));

            rotLockButton.onCheckEvent.AddListener(SetLockRotation);
            rotXLockButton.onCheckEvent.AddListener((bool value) => SetTurnAroundX(!value));
            rotYLockButton.onCheckEvent.AddListener((bool value) => SetTurnAroundY(!value));
            rotZLockButton.onCheckEvent.AddListener((bool value) => SetTurnAroundZ(!value));

            scaleLockButton.onCheckEvent.AddListener(SetLockScale);
            scaleXLockButton.onCheckEvent.AddListener((bool value) => SetScaleOnX(!value));
            scaleYLockButton.onCheckEvent.AddListener((bool value) => SetScaleOnY(!value));
            scaleZLockButton.onCheckEvent.AddListener((bool value) => SetScaleOnZ(!value));

            // Global events bindings
            GlobalState.ObjectMovingEvent.AddListener(UpdateTransformUI);
            GlobalState.ObjectConstraintEvent.AddListener((GameObject gobject) => UpdateUIOnSelectionChanged(null, null));
            Selection.onHoveredChanged.AddListener(SetConstraintTargetOnSelectionChanged);
            Selection.onSelectionChanged.AddListener(UpdateUIOnSelectionChanged);

            Init();
        }
Esempio n. 10
0
        private void Start()
        {
            // tmp
            // mixer.SetFloat("Volume_Master", -25.0f);

            GlobalState.Instance.onConnected.AddListener(OnConnected);

            displayOptionsButton  = panel.Find("DisplayOptionsButton").GetComponent <UIButton>();
            soundsOptionsButton   = panel.Find("SoundsOptionsButton").GetComponent <UIButton>();
            advancedOptionsButton = panel.Find("AdvancedOptionsButton").GetComponent <UIButton>();
            videoOptionsButton    = panel.Find("VideoOptionsButton").GetComponent <UIButton>();
            saveOptionsButton     = panel.Find("SaveOptionsButton").GetComponent <UIButton>();
            infoOptionsButton     = panel.Find("InfoOptionsButton").GetComponent <UIButton>();

            displaySubPanel  = panel.Find("DisplayOptions").gameObject;
            soundsSubPanel   = panel.Find("SoundsOptions").gameObject;
            advancedSubPanel = panel.Find("AdvancedOptions").gameObject;
            videoSubPanel    = panel.Find("VideoOptions").gameObject;
            saveSubPanel     = panel.Find("SaveOptions").gameObject;
            infoSubPanel     = panel.Find("InfoOptions").gameObject;

            worldGridCheckbox  = displaySubPanel.transform.Find("DisplayWorldGrid").GetComponent <UICheckbox>();
            displayGizmos      = displaySubPanel.transform.Find("DisplayGizmos").GetComponent <UICheckbox>();
            displayLocators    = displaySubPanel.transform.Find("DisplayLocators").GetComponent <UICheckbox>();
            displayAvatars     = displaySubPanel.transform.Find("DisplayAvatars").GetComponent <UICheckbox>();
            display3DCurves    = displaySubPanel.transform.Find("Display3DCurves").GetComponent <UICheckbox>();
            masterVolume       = soundsSubPanel.transform.Find("Master Volume").GetComponent <UISlider>();
            ambientVolume      = soundsSubPanel.transform.Find("Ambient Volume").GetComponent <UISlider>();
            uiVolume           = soundsSubPanel.transform.Find("UI Volume").GetComponent <UISlider>();
            assetBankDirectory = advancedSubPanel.transform.Find("AssetBankDirectory").GetComponent <UILabel>();
            rightHanded        = advancedSubPanel.transform.Find("RightHanded").GetComponent <UICheckbox>();
            forcePaletteOpen   = advancedSubPanel.transform.Find("ForcePaletteOpened").GetComponent <UICheckbox>();
            displayFPS         = advancedSubPanel.transform.Find("DisplayFPS").GetComponent <UICheckbox>();
            showConsoleWindow  = advancedSubPanel.transform.Find("ShowConsoleWindow").GetComponent <UICheckbox>();
            versionLabel       = infoSubPanel.transform.Find("Version").GetComponent <UILabel>();
            projectNameLabel   = saveSubPanel.transform.Find("ProjectName").GetComponent <UILabel>();
            saveInfoLabel      = saveSubPanel.transform.Find("InfoLabel").GetComponent <UILabel>();
            saveInfoLabel.gameObject.SetActive(false);
            mixerSaveButton = saveSubPanel.transform.Find("BlenderSaveButton").GetComponent <UIButton>();

            // Video Output buttons
            lowResButton              = videoSubPanel.transform.Find("LowResButton").GetComponent <UIButton>();
            midResButton              = videoSubPanel.transform.Find("MidResButton").GetComponent <UIButton>();
            highResButton             = videoSubPanel.transform.Find("HighResButton").GetComponent <UIButton>();
            videoOutputDirectoryLabel = videoSubPanel.transform.Find("VideoOutputDirectory").GetComponent <UILabel>();
            snapshotsDirectoryLabel   = videoSubPanel.transform.Find("SnapshotsDirectory").GetComponent <UILabel>();

            saveImage = saveShortcutButton.GetComponentInChildren <Image>();

            SceneManager.sceneDirtyEvent.AddListener(OnSceneDirtyChanged);
            SceneManager.sceneSavedEvent.AddListener(() => StartCoroutine(ShowSaveLoadInfo("Project saved", 2)));
            SceneManager.sceneLoadedEvent.AddListener(() =>
            {
                OnConnected();
                StartCoroutine(ShowSaveLoadInfo("Project loaded", 2));
            });

            Apply();

            if (null != versionLabel && versionLabel.Text.Length == 0)
            {
                versionLabel.Text = $"<color=#0079FF>VRtist Version</color>: {Version.VersionString}\n" +
                                    $"<color=#0079FF>Sync Version</color>: {Version.syncVersion}\n" +
                                    $"<color=#0079FF>Scene Type</color>: {SceneManager.GetSceneType()}";
            }

            OnSetDisplaySubPanel();
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        protected override void Awake()
        {
            base.Awake();

            if (!panel)
            {
                Debug.LogWarning("You forgot to give the Camera Panel to the Camera Tool.");
            }
            else
            {
                focalSlider                  = panel.Find("Focal");
                focusSlider                  = panel.Find("Focus");
                apertureSlider               = panel.Find("Aperture");
                enableDepthOfFieldCheckbox   = panel.Find("EnableDepthOfField").gameObject.GetComponent <UICheckbox>();
                showCameraFeedbackCheckbox   = panel.Find("ShowFeedback").gameObject.GetComponent <UICheckbox>();
                feedbackPositionningCheckbox = panel.Find("Feedback").gameObject.GetComponent <UICheckbox>();
                showDopesheetCheckbox        = panel.Find("ShowDopesheet").gameObject.GetComponent <UICheckbox>();
                showShotManagerCheckbox      = panel.Find("ShowShotManager").gameObject.GetComponent <UICheckbox>();
                showCameraPreviewCheckbox    = panel.Find("ShowCameraPreview").gameObject.GetComponent <UICheckbox>();
                showCameraFrustumCheckbox    = panel.Find("ShowFrustum").gameObject.GetComponent <UICheckbox>();
            }

            if (!dopesheetHandle)
            {
                Debug.LogWarning("You forgot to give the Dopesheet to the Camera Tool.");
            }
            else
            {
                //dopesheet = dopesheetHandle.GetComponentInChildren<Dopesheet>();
                dopesheetHandle.localScale = Vector3.zero; // si tous les tools ont une ref sur la dopesheet, qui la cache au demarrage? ToolsUIManager?
                dopesheetHandle.position   = Vector3.zero;
            }

            if (!shotManagerHandle)
            {
                Debug.LogWarning("You forgot to give the Shot Manager to the Camera Tool.");
            }
            else
            {
                shotManagerHandle.localScale = Vector3.zero; // si tous les tools ont une ref sur le shot manager, qui la cache au demarrage? ToolsUIManager?
                shotManagerHandle.position   = Vector3.zero;
            }

            if (!cameraPreviewHandle)
            {
                Debug.LogWarning("You forgot to give the CameraPreview to the Camera Tool.");
            }
            else
            {
                cameraPreviewWindow            = cameraPreviewHandle.GetComponentInChildren <CameraPreviewWindow>();
                cameraPreviewHandle.localScale = Vector3.zero;
                cameraPreviewHandle.position   = Vector3.zero;
            }


            Init();

            // Create tooltips
            SetTooltips();
            Tooltips.SetText(VRDevice.PrimaryController, Tooltips.Location.Joystick, Tooltips.Action.HoldVertical, "Zoom");

            // Camera list
            GlobalState.ObjectAddedEvent.AddListener(OnCameraAdded);
            GlobalState.ObjectRemovedEvent.AddListener(OnCameraRemoved);
            GlobalState.ObjectRenamedEvent.AddListener(OnCameraRenamed);
            SceneManager.clearSceneEvent.AddListener(OnClearScene);
            if (null != cameraList)
            {
                cameraList.ItemClickedEvent += OnSelectCameraItem;
            }
            cameraItemPrefab = Resources.Load <GameObject>("Prefabs/UI/CameraItem");
        }