Пример #1
0
        void OnEndEditTransform(float value, string attr)
        {
            // Expecting attr to be one of px, py, pz, rx, ry, rz, sx, sy, sz
            CommandMoveObjects command = new CommandMoveObjects();

            GameObject firstSelected = null;

            foreach (var selected in Selection.SelectedObjects)
            {
                if (null == firstSelected)
                {
                    firstSelected = selected;
                }
                Vector3 position = selected.transform.localPosition;
                Vector3 rotation = selected.transform.localEulerAngles;
                Vector3 scale    = selected.transform.localScale;

                if (attr[0] == 'p')
                {
                    switch (attr[1])
                    {
                    case 'x': position.x = value; break;

                    case 'y': position.y = value; break;

                    case 'z': position.z = value; break;
                    }
                }
                else if (attr[0] == 'r')
                {
                    switch (attr[1])
                    {
                    case 'x': rotation.x = value; break;

                    case 'y': rotation.y = value; break;

                    case 'z': rotation.z = value; break;
                    }
                }
                else if (attr[0] == 's')
                {
                    switch (attr[1])
                    {
                    case 'x': scale.x = value; break;

                    case 'y': scale.y = value; break;

                    case 'z': scale.z = value; break;
                    }
                }

                command.AddObject(selected, position, Quaternion.Euler(rotation), scale);
            }

            if (null != firstSelected)
            {
                command.Submit();
                UpdateTransformUI(firstSelected);
            }
        }
Пример #2
0
        public void ResetScale()
        {
            CommandMoveObjects command = new CommandMoveObjects();

            foreach (GameObject gobject in Selection.SelectedObjects)
            {
                command.AddObject(gobject, gobject.transform.localPosition, gobject.transform.localRotation, Vector3.one);
            }
            command.Submit();
        }
Пример #3
0
        public void ResetRotation()
        {
            CommandMoveObjects command = new CommandMoveObjects();

            foreach (GameObject gobject in Selection.SelectedObjects)
            {
                command.AddObject(gobject, gobject.transform.localPosition, Quaternion.identity, gobject.transform.localScale);
            }
            command.Submit();
        }