internal static void ResetGridSize()
        {
            if (!EditorSnapSettings.enabled)
            {
                return;
            }

            EditorSnapSettings.ResetMultiplier();
        }
        public void SetUp()
        {
            var go = new GameObject();

            m_Grid = go.AddComponent <Grid>();
            m_SceneViewGridManager     = SceneViewGridManager.instance;
            Selection.activeGameObject = go;
            Selection.selectionChanged();

            EditorSnapSettings.ResetSnapSettings();
        }
Example #3
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();
        }
        public void TearDown()
        {
            Selection.activeGameObject = null;
            Selection.selectionChanged();

            if (m_Grid != null)
            {
                Object.DestroyImmediate(m_Grid.gameObject);
                m_Grid = null;
            }
            EditorSnapSettings.ResetSnapSettings();
        }
Example #5
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();
            });
        }
 internal static void ResetGridSize()
 {
     EditorSnapSettings.ResetMultiplier();
 }