Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private bool showLocalAxisToggle = false;
- private void ShowLocalAxisComponentToggle()
- {
- EditorGUILayout.Space();
- EditorGUILayout.Space();
- ShowLocalAxis showLocalAxis = _transform.gameObject.GetComponent<ShowLocalAxis>();
- if (showLocalAxis == null)
- showLocalAxisToggle = false;
- else
- showLocalAxisToggle = true;
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Show local rotation handles", EditorStyles.boldLabel);
- EditorGUI.BeginChangeCheck();
- // We use GUILayout.Toggle here instead of EditorGUI toggle because they cause horizontal overflow
- showLocalAxisToggle = GUILayout.Toggle(showLocalAxisToggle, (showLocalAxisToggle ? "on" : "off" ));
- if (EditorGUI.EndChangeCheck())
- {
- if (showLocalAxisToggle == true)
- {
- showLocalAxis = _transform.gameObject.AddComponent<ShowLocalAxis>();
- int componentCount = _transform.GetComponents<Component>().Length;
- for (int i = 1; i < componentCount; i++)
- {
- UnityEditorInternal.ComponentUtility.MoveComponentUp(showLocalAxis);
- }
- }
- else
- {
- showLocalAxis.destroyWhenSafe = true;
- }
- }
- EditorGUILayout.EndHorizontal();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement