Exemplo n.º 1
0
        bool ShowToggleButton(string buttonLabel, string tooltip, GUIStyle buttonStyle)
        {
            bool  pressed = SnapSettings.GetValue <bool>("Toggle" + buttonLabel + transform.GetInstanceID());
            float width   = buttonLabel.GetWidth(EditorStyles.miniFont) + 12;
            int   spacing = buttonStyle == EditorStyles.miniButtonLeft ? -6 : 0;

            Rect position = EditorGUILayout.BeginVertical(GUILayout.Width(buttonLabel.GetWidth(EditorStyles.miniFont) + 16 + spacing), GUILayout.Height(EditorGUIUtility.singleLineHeight));

            EditorGUILayout.Space();
            pressed = EditorGUI.Toggle(new Rect(position.x + 4, position.y + 2, width, position.height - 1), pressed, buttonStyle);

            if (pressed)
            {
                EditorGUI.LabelField(new Rect(position.x + 8, position.y + 1, width, position.height - 1), new GUIContent(buttonLabel, tooltip), EditorStyles.whiteMiniLabel);
            }
            else
            {
                EditorGUI.LabelField(new Rect(position.x + 8, position.y + 1, width, position.height - 1), new GUIContent(buttonLabel, tooltip), EditorStyles.miniLabel);
            }

            if (pressed != SnapSettings.GetValue <bool>("Toggle" + buttonLabel + transform.GetInstanceID()))
            {
                for (int i = 0; i < Selection.transforms.Length; i++)
                {
                    Transform selectedTransform = Selection.transforms[i];
                    SnapSettings.SetValue("Toggle" + buttonLabel + selectedTransform.GetInstanceID(), pressed);
                    EditorUtility.SetDirty(selectedTransform);
                }
            }

            EditorGUILayout.EndVertical();

            return(SnapSettings.GetValue <bool>("Toggle" + buttonLabel + transform.GetInstanceID()));
        }
Exemplo n.º 2
0
 void GetSnapSettings()
 {
     moveX     = SnapSettings.GetValue <float>("moveX");
     moveY     = SnapSettings.GetValue <float>("moveY");
     moveZ     = SnapSettings.GetValue <float>("moveZ");
     rotation  = SnapSettings.GetValue <float>("rotation");
     scale     = SnapSettings.GetValue <float>("scale");
     gridSize  = SnapSettings.GetValue <int>("gridSize");
     showCubes = SnapSettings.GetValue <bool>("showCubes");
     showLines = SnapSettings.GetValue <bool>("showLines");
 }