Ejemplo n.º 1
0
        void AutoUISetting()
        {
            foreach (UIObject t in SetObjects) {
                if (t.ObjectToSet == null) {
                    continue;
                }

                switch (t.Option) {
                case SettingOption.Position:
                    prsFactorX = (float)System.Math.Round ((currentScreenRatio * (t.ObjectToSet.transform.position.x))
                        / editorScreenRatio, 6);
                    prsFactorY = (float)System.Math.Round ((currentScreenRatio * (t.ObjectToSet.transform.position.y))
                        / editorScreenRatio, 6);
                    prsFactorZ = (float)System.Math.Round ((currentScreenRatio * (t.ObjectToSet.transform.position.z))
                        / editorScreenRatio, 6);

                    prsFactorX = prsFactorX - t.ObjectToSet.transform.position.x;
                    prsFactorY = prsFactorY - t.ObjectToSet.transform.position.y;
                    prsFactorZ = prsFactorZ - t.ObjectToSet.transform.position.z;
                    if (t.Mode == SettingMode.Addition) {
                        prsFactorX = t.ObjectToSet.transform.position.x + (prsFactorX * t.SetMultiplier);
                        prsFactorY = t.ObjectToSet.transform.position.y + (prsFactorY * t.SetMultiplier);
                        prsFactorZ = t.ObjectToSet.transform.position.z + (prsFactorZ * t.SetMultiplier);
                    } else if (t.Mode == SettingMode.Subtraction) {
                        prsFactorX = t.ObjectToSet.transform.position.x - (prsFactorX * t.SetMultiplier);
                        prsFactorY = t.ObjectToSet.transform.position.y - (prsFactorY * t.SetMultiplier);
                        prsFactorZ = t.ObjectToSet.transform.position.z - (prsFactorZ * t.SetMultiplier);
                    }
                    currLoc = t.Axis;
                    if (currLoc == AxisToSet.X || currLoc == AxisToSet.XY || currLoc == AxisToSet.XYZ ||
                        currLoc == AxisToSet.XZ) {
                        t.ObjectToSet.transform.position = new Vector3 (prsFactorX, t.ObjectToSet.transform.position.y, t.ObjectToSet.transform.position.z);
                    }
                    if (currLoc == AxisToSet.Y || currLoc == AxisToSet.XY || currLoc == AxisToSet.XYZ ||
                        currLoc == AxisToSet.YZ) {
                        t.ObjectToSet.transform.position = new Vector3 (t.ObjectToSet.transform.position.x, prsFactorY, t.ObjectToSet.transform.position.z);
                    }
                    if (currLoc == AxisToSet.Z || currLoc == AxisToSet.XZ || currLoc == AxisToSet.XYZ ||
                        currLoc == AxisToSet.YZ) {
                        t.ObjectToSet.transform.position = new Vector3 (t.ObjectToSet.transform.position.x, t.ObjectToSet.transform.position.y, prsFactorZ);
                    }
                    break;

                case SettingOption.Scale:
                    prsFactorX = (float)System.Math.Round ((currentScreenRatio * t.ObjectToSet.transform.localScale.x) / editorScreenRatio, 6);
                    prsFactorY = (float)System.Math.Round ((currentScreenRatio * t.ObjectToSet.transform.localScale.y) / editorScreenRatio, 6);
                    prsFactorZ = (float)System.Math.Round ((currentScreenRatio * t.ObjectToSet.transform.localScale.z) / editorScreenRatio, 6);

                    prsFactorX = prsFactorX - t.ObjectToSet.transform.localScale.x;
                    prsFactorY = prsFactorY - t.ObjectToSet.transform.localScale.y;
                    prsFactorZ = prsFactorZ - t.ObjectToSet.transform.localScale.z;
                    if (t.Mode == SettingMode.Addition) {
                        prsFactorX = t.ObjectToSet.transform.localScale.x + (prsFactorX * t.SetMultiplier);
                        prsFactorY = t.ObjectToSet.transform.localScale.y + (prsFactorY * t.SetMultiplier);
                        prsFactorZ = t.ObjectToSet.transform.localScale.z + (prsFactorZ * t.SetMultiplier);
                    } else if (t.Mode == SettingMode.Subtraction) {
                        prsFactorX = t.ObjectToSet.transform.localScale.x - (prsFactorX * t.SetMultiplier);
                        prsFactorY = t.ObjectToSet.transform.localScale.y - (prsFactorY * t.SetMultiplier);
                        prsFactorZ = t.ObjectToSet.transform.localScale.z - (prsFactorZ * t.SetMultiplier);
                    }
                    currLoc = t.Axis;
                    if (currLoc == AxisToSet.X || currLoc == AxisToSet.XY || currLoc == AxisToSet.XYZ ||
                        currLoc == AxisToSet.XZ) {
                        t.ObjectToSet.transform.localScale = new Vector3 (prsFactorX, t.ObjectToSet.transform.localScale.y, t.ObjectToSet.transform.localScale.z);
                    }
                    if (currLoc == AxisToSet.Y || currLoc == AxisToSet.XY || currLoc == AxisToSet.XYZ ||
                        currLoc == AxisToSet.YZ) {
                        t.ObjectToSet.transform.localScale = new Vector3 (t.ObjectToSet.transform.localScale.x, prsFactorY, t.ObjectToSet.transform.localScale.z);
                    }
                    if (currLoc == AxisToSet.Z || currLoc == AxisToSet.XZ || currLoc == AxisToSet.XYZ ||
                        currLoc == AxisToSet.YZ) {
                        t.ObjectToSet.transform.localScale = new Vector3 (t.ObjectToSet.transform.localScale.x, t.ObjectToSet.transform.localScale.y, prsFactorZ);
                    }
                    break;

                case SettingOption.CameraFoV:
                    if (t.ObjectToSet.camera == null) {
                        continue;

                    }
                    float fov = ((currentScreenRatio - editorScreenRatio) * 7) / 0.42f;
                    t.ObjectToSet.camera.fov -= fov;
                    break;

                case SettingOption.None:
                case SettingOption.Rotation:
                default:
                    break;

                }
            }
        }
Ejemplo n.º 2
0
        void AutoUISetting()
        {
            foreach (UIObject t in elements)
            {
                if (null == t.objectToSet)
                {
                    continue;
                }

                switch (t.option)
                {
                case UISettingOption.Position:
                    if (isCamBase)
                    {
                        _currLoc = t.axis;
                        float   x1  = (_currentWidth - _editorWidth);
                        Vector3 pos = t.objectToSet.transform.localPosition;
                        if (_currLoc == AxisToSet.X || _currLoc == AxisToSet.XY || _currLoc == AxisToSet.XYZ || _currLoc == AxisToSet.XZ)
                        {
                            if (t.mode == UISettingMode.Addition)
                            {
                                pos.x += (x1 * t.multiplier);
                            }
                            else if (t.mode == UISettingMode.Subtraction)
                            {
                                pos.x -= (x1 * t.multiplier);
                            }
                        }
                        if (_currLoc == AxisToSet.Y || _currLoc == AxisToSet.XY || _currLoc == AxisToSet.XYZ || _currLoc == AxisToSet.YZ)
                        {
                            if (t.mode == UISettingMode.Addition)
                            {
                                pos.y += (x1 * t.multiplier);
                            }
                            else if (t.mode == UISettingMode.Subtraction)
                            {
                                pos.y -= (x1 * t.multiplier);
                            }
                        }
                        if (_currLoc == AxisToSet.Z || _currLoc == AxisToSet.XZ || _currLoc == AxisToSet.XYZ || _currLoc == AxisToSet.YZ)
                        {
                            if (t.mode == UISettingMode.Addition)
                            {
                                pos.z += (x1 * t.multiplier);
                            }
                            else if (t.mode == UISettingMode.Subtraction)
                            {
                                pos.z -= (x1 * t.multiplier);
                            }
                        }
                        t.objectToSet.transform.localPosition = pos;
                    }
                    else
                    {
                        prsFactorX = (float)System.Math.Round((_currentScreenRatio * (t.objectToSet.transform.position.x)) / _editorScreenRatio, 6);
                        prsFactorY = (float)System.Math.Round((_currentScreenRatio * (t.objectToSet.transform.position.y)) / _editorScreenRatio, 6);
                        prsFactorZ = (float)System.Math.Round((_currentScreenRatio * (t.objectToSet.transform.position.z)) / _editorScreenRatio, 6);

                        prsFactorX = prsFactorX - t.objectToSet.transform.position.x;
                        prsFactorY = prsFactorY - t.objectToSet.transform.position.y;
                        prsFactorZ = prsFactorZ - t.objectToSet.transform.position.z;
                        if (t.mode == UISettingMode.Addition)
                        {
                            prsFactorX = t.objectToSet.transform.position.x + (prsFactorX * t.multiplier);
                            prsFactorY = t.objectToSet.transform.position.y + (prsFactorY * t.multiplier);
                            prsFactorZ = t.objectToSet.transform.position.z + (prsFactorZ * t.multiplier);
                        }
                        else if (t.mode == UISettingMode.Subtraction)
                        {
                            prsFactorX = t.objectToSet.transform.position.x - (prsFactorX * t.multiplier);
                            prsFactorY = t.objectToSet.transform.position.y - (prsFactorY * t.multiplier);
                            prsFactorZ = t.objectToSet.transform.position.z - (prsFactorZ * t.multiplier);
                        }
                        _currLoc = t.axis;
                        if (_currLoc == AxisToSet.X || _currLoc == AxisToSet.XY || _currLoc == AxisToSet.XYZ || _currLoc == AxisToSet.XZ)
                        {
                            t.objectToSet.transform.position = new Vector3(prsFactorX, t.objectToSet.transform.position.y,
                                                                           t.objectToSet.transform.position.z);
                        }
                        if (_currLoc == AxisToSet.Y || _currLoc == AxisToSet.XY || _currLoc == AxisToSet.XYZ || _currLoc == AxisToSet.YZ)
                        {
                            t.objectToSet.transform.position = new Vector3(t.objectToSet.transform.position.x, prsFactorY,
                                                                           t.objectToSet.transform.position.z);
                        }
                        if (_currLoc == AxisToSet.Z || _currLoc == AxisToSet.XZ || _currLoc == AxisToSet.XYZ || _currLoc == AxisToSet.YZ)
                        {
                            t.objectToSet.transform.position = new Vector3(t.objectToSet.transform.position.x,
                                                                           t.objectToSet.transform.position.y, prsFactorZ);
                        }
                    }
                    break;

                case UISettingOption.Scale:
                    prsFactorX = (float)System.Math.Round((_currentScreenRatio * t.objectToSet.transform.localScale.x) / _editorScreenRatio,
                                                          6);
                    prsFactorY = (float)System.Math.Round((_currentScreenRatio * t.objectToSet.transform.localScale.y) / _editorScreenRatio,
                                                          6);
                    prsFactorZ = (float)System.Math.Round((_currentScreenRatio * t.objectToSet.transform.localScale.z) / _editorScreenRatio,
                                                          6);

                    prsFactorX = prsFactorX - t.objectToSet.transform.localScale.x;
                    prsFactorY = prsFactorY - t.objectToSet.transform.localScale.y;
                    prsFactorZ = prsFactorZ - t.objectToSet.transform.localScale.z;
                    if (t.mode == UISettingMode.Addition)
                    {
                        prsFactorX = t.objectToSet.transform.localScale.x + (prsFactorX * t.multiplier);
                        prsFactorY = t.objectToSet.transform.localScale.y + (prsFactorY * t.multiplier);
                        prsFactorZ = t.objectToSet.transform.localScale.z + (prsFactorZ * t.multiplier);
                    }
                    else if (t.mode == UISettingMode.Subtraction)
                    {
                        prsFactorX = t.objectToSet.transform.localScale.x - (prsFactorX * t.multiplier);
                        prsFactorY = t.objectToSet.transform.localScale.y - (prsFactorY * t.multiplier);
                        prsFactorZ = t.objectToSet.transform.localScale.z - (prsFactorZ * t.multiplier);
                    }
                    _currLoc = t.axis;
                    if (_currLoc == AxisToSet.X || _currLoc == AxisToSet.XY || _currLoc == AxisToSet.XYZ || _currLoc == AxisToSet.XZ)
                    {
                        t.objectToSet.transform.localScale = new Vector3(prsFactorX, t.objectToSet.transform.localScale.y,
                                                                         t.objectToSet.transform.localScale.z);
                    }
                    if (_currLoc == AxisToSet.Y || _currLoc == AxisToSet.XY || _currLoc == AxisToSet.XYZ || _currLoc == AxisToSet.YZ)
                    {
                        t.objectToSet.transform.localScale = new Vector3(t.objectToSet.transform.localScale.x, prsFactorY,
                                                                         t.objectToSet.transform.localScale.z);
                    }
                    if (_currLoc == AxisToSet.Z || _currLoc == AxisToSet.XZ || _currLoc == AxisToSet.XYZ || _currLoc == AxisToSet.YZ)
                    {
                        t.objectToSet.transform.localScale = new Vector3(t.objectToSet.transform.localScale.x,
                                                                         t.objectToSet.transform.localScale.y, prsFactorZ);
                    }
                    break;

                case UISettingOption.None:
                    break;

                default:
                    break;
                }
            }
        }