MegaSelectionEditor.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #if false
  2. using UnityEngine;
  3. using UnityEditor;
  4. [CanEditMultipleObjects, CustomEditor(typeof(MegaSelection))]
  5. public class MegaSelectionEditor : MegaModifierEditor
  6. {
  7. public override string GetHelpString() { return "Selection Modifier by Chris West"; }
  8. //public override Texture LoadImage() { return (Texture)EditorGUIUtility.LoadRequired("MegaFiers\\bend_help.png"); }
  9. public override bool DisplayCommon() { return false; }
  10. public override bool Inspector()
  11. {
  12. MegaSelection mod = (MegaSelection)target;
  13. EditorGUIUtility.LookLikeControls();
  14. mod.weight = EditorGUILayout.FloatField("Weight", mod.weight);
  15. return false;
  16. }
  17. public override void DrawSceneGUI()
  18. {
  19. MegaSelection mod = (MegaSelection)target;
  20. MegaModifiers mc = mod.gameObject.GetComponent<MegaModifiers>();
  21. float[] sel = mod.GetSel();
  22. if ( mc != null && sel != null )
  23. {
  24. Color col = Color.black;
  25. Matrix4x4 tm = mod.gameObject.transform.localToWorldMatrix;
  26. Handles.matrix = Matrix4x4.identity;
  27. for ( int i = 0; i < sel.Length; i++ )
  28. {
  29. float w = sel[i];
  30. if ( w > 0.5f )
  31. col = Color.Lerp(Color.green, Color.red, (w - 0.5f) * 2.0f);
  32. else
  33. col = Color.Lerp(Color.blue, Color.green, w * 2.0f);
  34. Handles.color = col;
  35. Vector3 p = tm.MultiplyPoint(mc.sverts[i]);
  36. MegaHandles.DotCap(i, p, Quaternion.identity, 0.01f);
  37. }
  38. Handles.matrix = Matrix4x4.identity;
  39. }
  40. }
  41. }
  42. #endif