TC_RawImageEditor.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4. namespace TerrainComposer2
  5. {
  6. [CustomEditor(typeof(TC_RawImage))]
  7. public class TC_RawImageEditor : Editor
  8. {
  9. void OnEnable()
  10. {
  11. Transform t = ((MonoBehaviour)target).transform;
  12. t.hideFlags = HideFlags.NotEditable | HideFlags.HideInInspector;
  13. }
  14. public override void OnInspectorGUI()
  15. {
  16. if (TC_Settings.instance == null) return;
  17. if (TC_Settings.instance.debugMode) DrawDefaultInspector(); else DrawCustomInspector();
  18. }
  19. void DrawCustomInspector()
  20. {
  21. TC_RawImage rawImage = (TC_RawImage)target;
  22. TD.DrawSpacer();
  23. TD.DrawLabelWidthUnderline("Loaded stamp texture for GPU", 14);
  24. GUILayout.Space(25);
  25. Rect rect = GUILayoutUtility.GetLastRect();
  26. float width = TC_NodeWindow.window.position.width - (rect.x * 2);
  27. if (width > 768) width = 768;
  28. float min = (768 - width);
  29. if (min > 50) min = 50;
  30. TD.DrawTexture(new Rect(rect.x, rect.y + width, width, -width), rawImage.tex, Color.white);
  31. GUILayout.Space(width - min);
  32. TD.DrawSpacer();
  33. TD.DrawLabelWidthUnderline("Path", 14);
  34. EditorGUILayout.BeginVertical("Box");
  35. EditorGUILayout.LabelField(rawImage.path);
  36. EditorGUILayout.EndVertical();
  37. GUILayout.Space(10);
  38. TD.DrawLabelWidthUnderline("Details", 14);
  39. EditorGUILayout.BeginVertical("Box");
  40. EditorGUILayout.BeginHorizontal();
  41. EditorGUILayout.PrefixLabel("Resolution");
  42. EditorGUILayout.LabelField(rawImage.resolution.ToString());
  43. EditorGUILayout.EndHorizontal();
  44. EditorGUILayout.BeginHorizontal();
  45. EditorGUILayout.PrefixLabel("Node References");
  46. EditorGUILayout.LabelField(rawImage.referenceCount.ToString());
  47. EditorGUILayout.EndHorizontal();
  48. EditorGUILayout.EndVertical();
  49. TD.DrawSpacer();
  50. }
  51. }
  52. }