TestColorChange.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using UnityEngine;
  3. public class TestColorChange : MonoBehaviour
  4. {
  5. private void Start()
  6. {
  7. this.m_test_stats = new ColorPalette.Status();
  8. Renderer component = base.transform.GetComponent<Renderer>();
  9. Texture2D texture2D = component.material.mainTexture as Texture2D;
  10. this.m_new_tex = new Texture2D(texture2D.width, texture2D.height, TextureFormat.RGBA32, false, true);
  11. this.m_bySrcColor = UTY.GetPixelArray(texture2D);
  12. component.material.mainTexture = this.m_new_tex;
  13. }
  14. private void Update()
  15. {
  16. this.m_test_stats.base_color.hue = this.main_hue;
  17. this.m_test_stats.base_color.sat = this.main_sat;
  18. this.m_test_stats.base_color.brightness = this.main_brightness;
  19. this.m_test_stats.base_color.contrast = this.main_contrast;
  20. this.m_test_stats.shadow_color.hue = this.shadow_hue;
  21. this.m_test_stats.shadow_color.sat = this.shadow_sat;
  22. this.m_test_stats.shadow_color.brightness = this.shadow_brightness;
  23. this.m_test_stats.shadow_color.contrast = this.shadow_contrast;
  24. this.m_test_stats.shadow_threshold = this.shadow_threshold;
  25. UTY.ConvertColor(this.m_test_stats, this.m_bySrcColor, ref this.m_new_tex);
  26. this.main_hue = this.m_test_stats.base_color.hue;
  27. this.main_sat = this.m_test_stats.base_color.sat;
  28. this.main_brightness = this.m_test_stats.base_color.brightness;
  29. this.main_contrast = this.m_test_stats.base_color.contrast;
  30. this.shadow_hue = this.m_test_stats.shadow_color.hue;
  31. this.shadow_sat = this.m_test_stats.shadow_color.sat;
  32. this.shadow_brightness = this.m_test_stats.shadow_color.brightness;
  33. this.shadow_contrast = this.m_test_stats.shadow_color.contrast;
  34. this.shadow_threshold = this.m_test_stats.shadow_threshold;
  35. }
  36. public int main_hue;
  37. public int main_sat = 128;
  38. public int main_brightness = 260;
  39. public int main_contrast = 128;
  40. public int shadow_threshold = 128;
  41. public int shadow_hue = 128;
  42. public int shadow_sat = 128;
  43. public int shadow_brightness = 260;
  44. public int shadow_contrast = 128;
  45. private ColorPalette.Status m_test_stats;
  46. private byte[] m_bySrcColor;
  47. private Texture2D m_new_tex;
  48. }