A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.5KB

  1. using UnityEngine;
  2. namespace GamecraftModdingAPI.Interface.IMGUI
  3. {
  4. public class Image : UIElement
  5. {
  6. private bool automaticLayout = false;
  7. public Texture Texture { get; set; }
  8. public Rect Box { get; set; } = Rect.zero;
  9. public void OnGUI()
  10. {
  11. //if (Texture == null) return;
  12. if (automaticLayout)
  13. {
  14. GUILayout.Label(Texture, Constants.Default.label);
  15. }
  16. else
  17. {
  18. GUI.Label(Box, Texture, Constants.Default.label);
  19. }
  20. }
  21. public string Name { get; }
  22. public bool Enabled { set; get; } = true;
  23. public Image(Texture texture = null, string name = null)
  24. {
  25. automaticLayout = true;
  26. Texture = texture;
  27. if (name == null)
  28. {
  29. if (texture == null)
  30. {
  31. this.Name = typeof(Image).FullName + "::" + texture;
  32. }
  33. else
  34. {
  35. this.Name = typeof(Image).FullName + "::" + texture.name + "(" + texture.width + "x" + texture.height + ")";
  36. }
  37. }
  38. else
  39. {
  40. this.Name = name;
  41. }
  42. IMGUIManager.AddElement(this);
  43. }
  44. public Image(Rect box, Texture texture = null, string name = null) : this(texture, name)
  45. {
  46. this.Box = box;
  47. automaticLayout = false;
  48. }
  49. }
  50. }