VDAmbientOcclusionWindow.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. VertexDirt plug-in for Unity
  3. Copyright 2014-2015, Zoltan Farago, All rights reserved.
  4. */
  5. class VDAmbientOcclusionWindow extends EditorWindow {
  6. @MenuItem ("Tools/VertexDirt/Ambient Occlusion")
  7. static function ShowWindow () {
  8. var window : VDAmbientOcclusionWindow = ScriptableObject.CreateInstance.<VDAmbientOcclusionWindow>();
  9. window.position = Rect(100,100, 260,400);
  10. window.minSize = Vector2 (260,400);
  11. window.maxSize = Vector2 (260,400);
  12. window.titleContent = GUIContent("VD Ambient Occlusion");
  13. window.ShowUtility();
  14. VertexDirt.SetPreset (VDPRESET.AMBIENTOCCLUSION);
  15. }
  16. function OnGUI() {
  17. GUILayout.Label ("Occlusion distance");
  18. VertexDirt.samplingDistance = EditorGUILayout.Slider(VertexDirt.samplingDistance,0.01, 1000.0);
  19. GUILayout.Space(10);
  20. GUILayout.BeginHorizontal();
  21. GUILayout.Label ("Edge smooth enabled");
  22. GUILayout.FlexibleSpace();
  23. VertexDirt.edgeSmooth = GUILayout.Toggle(VertexDirt.edgeSmooth, "");
  24. GUILayout.EndHorizontal();
  25. GUILayout.Space(10);
  26. GUILayout.Label ("Sampling angle");
  27. VertexDirt.samplingAngle = EditorGUILayout.Slider(VertexDirt.samplingAngle,100, 150);
  28. // VertexDirt.skyCube = EditorGUILayout.ObjectField(VertexDirt.skyCube, Material, true);
  29. GUILayout.Space(10);
  30. GUILayout.Label ("Sky color");
  31. VertexDirt.skyColor = EditorGUILayout.ColorField(VertexDirt.skyColor);
  32. GUILayout.Space(10);
  33. GUILayout.Label ("Shadow color");
  34. VertexDirt.globalOccluderColor = EditorGUILayout.ColorField(VertexDirt.globalOccluderColor);
  35. // globalOccluderColor = Color.black;
  36. if (Selection.gameObjects) {
  37. if (GUI.Button(Rect(10,350,240,40),"Start") ) {
  38. var tempTime : float = EditorApplication.timeSinceStartup;
  39. VertexDirt.Dirt(Selection.GetFiltered(Transform, SelectionMode.Deep));
  40. Debug.Log ("Dirt time: " + (EditorApplication.timeSinceStartup - tempTime));
  41. }
  42. }
  43. }
  44. }