UnityImage3D.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using CommonUI.Display;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using UnityEngine;
  7. namespace CommonUI_Unity3D.Impl
  8. {
  9. public class UnityImage3D : Image, IUnityImageInterface
  10. {
  11. internal int mLogicW, mLogicH;
  12. internal float mMaxU, mMaxV;
  13. private RenderTexture mTexture;
  14. public override int Width
  15. {
  16. get
  17. {
  18. return mLogicW;
  19. }
  20. }
  21. public override int Height
  22. {
  23. get
  24. {
  25. return mLogicH;
  26. }
  27. }
  28. public override float MaxU
  29. {
  30. get
  31. {
  32. return mMaxU;
  33. }
  34. }
  35. public override float MaxV
  36. {
  37. get
  38. {
  39. return mMaxV;
  40. }
  41. }
  42. public Texture Texture
  43. {
  44. get
  45. {
  46. return mTexture;
  47. }
  48. }
  49. public Texture TextureMask
  50. {
  51. get
  52. {
  53. return null;
  54. }
  55. }
  56. internal static void FilterTexture(RenderTexture tex)
  57. {
  58. tex.filterMode = FilterMode.Bilinear;
  59. tex.wrapMode = TextureWrapMode.Clamp;
  60. tex.anisoLevel = 0;
  61. tex.mipMapBias = 0;
  62. }
  63. public UnityImage3D(RenderTexture tex, string name)
  64. {
  65. this.name = name;
  66. if (tex == null) { Debug.Log("Create UnityImage3D Error tex = null"); }
  67. this.mTexture = tex;
  68. this.mTexture.name = name;
  69. FilterTexture(tex);
  70. this.mLogicW = tex.width;
  71. this.mLogicH = tex.height;
  72. this.mMaxU = 1f;
  73. this.mMaxV = 1f;
  74. }
  75. protected override void Disposing()
  76. {
  77. if (mTexture != null)
  78. {
  79. RenderTexture.Destroy(mTexture);
  80. mTexture = null;
  81. }
  82. }
  83. public override void CopyPixels(Image src, int sx, int sy, int sw, int sh, int dx, int dy)
  84. {
  85. //do nothing.
  86. }
  87. public override void Flush()
  88. {
  89. //do nothing.
  90. }
  91. }
  92. }