Esempio n. 1
0
        void OnMoveValueChanged(ChangeEvent <Vector3> evt)
        {
            var value = evt.newValue;

            if (m_MoveLinkedField.linked)
            {
                value = evt.newValue.x * Vector3.one;
            }

            EditorSnapSettings.move = value;
            EditorSnapSettings.Save();
        }
Esempio n. 2
0
        protected override void OnEnable()
        {
            base.OnEnable();

            rootVisualElement.styleSheets.Add((StyleSheet)EditorGUIUtility.Load("StyleSheets/SceneViewToolbarElements/SnapWindowsCommon.uss"));
            rootVisualElement.Add(new SnapSettingsHeader(L10n.Tr("Increment Snapping"), ResetValues));

            // Move
            m_MoveLinkedField = new LinkedVector3Field(L10n.Tr("Move"))
            {
                name = "Move"
            };
            m_MoveLinkedField.value  = EditorSnapSettings.move;
            m_MoveLinkedField.linked = Mathf.Approximately(m_MoveLinkedField.value.x, m_MoveLinkedField.value.y) &&
                                       Mathf.Approximately(m_MoveLinkedField.value.x, m_MoveLinkedField.value.z);
            rootVisualElement.Add(m_MoveLinkedField);

            EditorSnapSettings.moveChanged += (value) => m_MoveLinkedField.SetValueWithoutNotify(value);
            m_MoveLinkedField.RegisterValueChangedCallback(OnMoveValueChanged);

            // Rotate
            var rotate = new FloatField(L10n.Tr("Rotate"))
            {
                name = "Rotate"
            };

            rotate.value = EditorSnapSettings.rotate;
            rootVisualElement.Add(rotate);

            EditorSnapSettings.rotateChanged += (value) => rotate.SetValueWithoutNotify(value);
            rotate.RegisterValueChangedCallback(evt =>
            {
                EditorSnapSettings.rotate = evt.newValue;
                EditorSnapSettings.Save();
            });

            // Scale
            var scale = new FloatField(L10n.Tr("Scale"))
            {
                name = "Scale"
            };

            scale.value = EditorSnapSettings.scale;
            rootVisualElement.Add(scale);

            EditorSnapSettings.scaleChanged += (value) => scale.SetValueWithoutNotify(value);
            scale.RegisterValueChangedCallback(evt =>
            {
                EditorSnapSettings.scale = evt.newValue;
                EditorSnapSettings.Save();
            });
        }