Example #1
0
    private void OnEnable()
    {
        SeparatorStyle                  = new GUIStyle();
        SeparatorStyle.fontSize         = 15;
        SeparatorStyle.fontStyle        = FontStyle.Bold;
        SeparatorStyle.alignment        = TextAnchor.MiddleCenter;
        SeparatorStyle.normal.textColor = Color.grey;

        _show = new AnimBool(false);
        _show.valueChanged.AddListener(Repaint);

        Trans = (Transform)target;

        if (Resources.Load("MultiAT/LastSettings"))
        {
            MultiAssetSettings MAT = (MultiAssetSettings)Resources.Load("MultiAT/LastSettings");
            MultiAssetTransformUtility.SettingsToTransform(MAT, this);
        }
    }
    private void OnGUI()
    {
        if (_showSearches)
        {
            SearchBar();
        }
        else
        {
            if (currentSettings)
            {
                EditorGUI.DrawRect(GUILayoutUtility.GetRect(300, 1), Color.grey);
                EditorGUILayout.LabelField("Rotation", SeparatorStyle);

                EditorGUILayout.BeginHorizontal();
                EditorGUIUtility.labelWidth = 15;
                currentSettings._xRotate    = EditorGUILayout.Toggle("X", currentSettings._xRotate, GUILayout.ExpandWidth(false));
                currentSettings._yRotate    = EditorGUILayout.Toggle("Y", currentSettings._yRotate, GUILayout.ExpandWidth(false));
                currentSettings._zRotate    = EditorGUILayout.Toggle("Z", currentSettings._zRotate, GUILayout.ExpandWidth(false));
                EditorGUIUtility.labelWidth = 0;
                EditorGUILayout.EndHorizontal();

                currentSettings._deegreesRotationB = EditorGUILayout.FloatField("min Deegrees", currentSettings._deegreesRotationB, GUILayout.ExpandWidth(false));
                currentSettings._deegreesRotationA = EditorGUILayout.FloatField("max Deegrees", currentSettings._deegreesRotationA, GUILayout.ExpandWidth(false));

                currentSettings._RotateOnWorldAxis = EditorGUILayout.Toggle("Rotating on " + currentSettings.CurrentStateR + " axis", currentSettings._RotateOnWorldAxis);
                if (currentSettings._RotateOnWorldAxis)
                {
                    currentSettings.CurrentStateR = "WORLD";
                    currentSettings.RotationSpace = Space.World;
                }
                else
                {
                    currentSettings.CurrentStateR = "LOCAL";
                    currentSettings.RotationSpace = Space.Self;
                }
                //----------------------------------------------------------------------------------------------------------------------
                EditorGUI.DrawRect(GUILayoutUtility.GetRect(300, 1), Color.grey);
                EditorGUILayout.LabelField("Scale", SeparatorStyle);
                //----------------------------------------------------------------------------------------------------------------------
                EditorGUILayout.BeginHorizontal();
                EditorGUIUtility.labelWidth = 15;
                currentSettings._xScale     = EditorGUILayout.Toggle("X", currentSettings._xScale, GUILayout.ExpandWidth(false));
                currentSettings._yScale     = EditorGUILayout.Toggle("Y", currentSettings._yScale, GUILayout.ExpandWidth(false));
                currentSettings._zScale     = EditorGUILayout.Toggle("Z", currentSettings._zScale, GUILayout.ExpandWidth(false));
                EditorGUIUtility.labelWidth = 0;
                EditorGUILayout.EndHorizontal();

                currentSettings._UnitsScaleB = EditorGUILayout.FloatField("min Scale", currentSettings._UnitsScaleB, GUILayout.ExpandWidth(false));
                currentSettings._UnitsScaleA = EditorGUILayout.FloatField("max Scale", currentSettings._UnitsScaleA, GUILayout.ExpandWidth(false));
            }
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Load"))
            {
                MultiAssetTransformUtility.SettingsToTransform(currentSettings, multiAT);
                AssetDatabase.SaveAssets();
                Close();
            }
            if (GUILayout.Button("Cancel"))
            {
                _showSearches = true;
            }

            GUILayout.EndHorizontal();
        }
    }