MegaShapeLightMapWindow.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #if UNITY_EDITOR
  2. using UnityEngine;
  3. using UnityEditor;
  4. // Do this with icons
  5. public class MegaShapeLightMapWindow : EditorWindow
  6. {
  7. static public void Init()
  8. {
  9. MegaShapeLightMapWindow window = ScriptableObject.CreateInstance<MegaShapeLightMapWindow>();
  10. window.position = new Rect(Screen.width / 2, Screen.height / 2, 250, 150);
  11. window.ShowUtility();
  12. }
  13. void OnGUI()
  14. {
  15. if ( Selection.activeGameObject == null )
  16. return;
  17. MegaShape shape = Selection.activeGameObject.GetComponent<MegaShape>();
  18. if ( shape == null )
  19. return;
  20. //UnwrapParam uv1 = new UnwrapParam();
  21. //UnwrapParam.SetDefaults(out uv1);
  22. //loft.genLightMap = EditorGUILayout.BeginToggleGroup("Gen LightMap", loft.genLightMap);
  23. shape.angleError = EditorGUILayout.Slider("Angle Error", shape.angleError, 0.0f, 1.0f);
  24. shape.areaError = EditorGUILayout.Slider("Area Error", shape.areaError, 0.0f, 1.0f);
  25. shape.hardAngle = EditorGUILayout.FloatField("Hard Angle", shape.hardAngle);
  26. shape.packMargin = EditorGUILayout.FloatField("Pack Margin", shape.packMargin);
  27. EditorStyles.textField.wordWrap = false;
  28. EditorGUILayout.BeginHorizontal();
  29. if ( GUILayout.Button("Build") )
  30. {
  31. UnwrapParam uv = new UnwrapParam();
  32. //UnwrapParam.SetDefaults(out uv);
  33. uv.angleError = shape.angleError;
  34. uv.areaError = shape.areaError;
  35. uv.hardAngle = shape.hardAngle;
  36. uv.packMargin = shape.packMargin;
  37. Unwrapping.GenerateSecondaryUVSet(shape.shapemesh, uv);
  38. this.Close();
  39. }
  40. if ( GUILayout.Button("Cancel") )
  41. {
  42. this.Close();
  43. }
  44. EditorGUILayout.EndHorizontal();
  45. }
  46. }
  47. #endif