Advertisement
napland

CustomTransformInspector.AlignmentInspector

Aug 19th, 2016
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. private void AlignmentInspector()
  2. {
  3. EditorGUILayout.LabelField("Alignment", EditorStyles.boldLabel, layoutMaxWidth);
  4. alignTo = (AlignToType)EditorGUILayout.EnumPopup("Align to", alignTo, layoutMaxWidth);
  5. alignmentAxis = (AxisFlag)EditorGUILayout.EnumMaskField("Axis", alignmentAxis, layoutMaxWidth);
  6.  
  7. string buttonLabel = "Select another object to align to";
  8. bool enableButton = false;
  9. Transform[] selectedTransforms = Selection.transforms;
  10. if (selectedTransforms.Length > 1)
  11. {
  12. if (alignTo == AlignToType.lastSelected)
  13. {
  14. buttonLabel = "Align to " + selectedTransforms[selectedTransforms.Length - 1].name;
  15. }
  16. else
  17. {
  18. buttonLabel = "Align to " + selectedTransforms[0].name;
  19. }
  20. enableButton = true;
  21. }
  22.  
  23. GUI.enabled = enableButton;
  24. if (Button(buttonLabel))
  25. {
  26. AlignTo(alignTo, alignmentAxis);
  27. }
  28. GUI.enabled = true;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement