LayaSkyboxPanoramicShaderGUI.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Unity C# reference source
  2. // Copyright (c) Unity Technologies. For terms of use, see
  3. // https://unity3d.com/legal/licenses/Unity_Reference_Only_License
  4. using UnityEngine;
  5. using UnityEditor;
  6. using UnityEditor.AnimatedValues;
  7. using UnityEditorInternal;
  8. using UnityEditor.Build;
  9. namespace UnityEditor
  10. {
  11. internal class LayaSkyboxPanoramicShaderGUI : ShaderGUI
  12. {
  13. readonly AnimBool m_ShowLatLongLayout = new AnimBool();
  14. readonly AnimBool m_ShowMirrorOnBack = new AnimBool();
  15. readonly AnimBool m_Show3DControl = new AnimBool();
  16. bool m_Initialized = false;
  17. public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
  18. {
  19. if (!m_Initialized)
  20. {
  21. m_ShowLatLongLayout.valueChanged.AddListener(materialEditor.Repaint);
  22. m_ShowMirrorOnBack.valueChanged.AddListener(materialEditor.Repaint);
  23. m_Show3DControl.valueChanged.AddListener(materialEditor.Repaint);
  24. m_Initialized = true;
  25. }
  26. // Allow the default implementation to set widths for consistency for common properties.
  27. float lw = EditorGUIUtility.labelWidth;
  28. materialEditor.SetDefaultGUIWidths();
  29. ShowProp(materialEditor, FindProperty("tintColor", props));
  30. ShowProp(materialEditor, FindProperty("exposure", props));
  31. ShowProp(materialEditor, FindProperty("rotation", props));
  32. ShowProp(materialEditor, FindProperty("panoramicTexture", props));
  33. EditorGUIUtility.labelWidth = lw;
  34. //m_ShowLatLongLayout.target = ShowProp(materialEditor, FindProperty("_Mapping", props)) == 1;
  35. //if (EditorGUILayout.BeginFadeGroup(m_ShowLatLongLayout.faded))
  36. //{
  37. //m_ShowMirrorOnBack.target = ShowProp(materialEditor, FindProperty("_ImageType", props)) == 1;
  38. //if (EditorGUILayout.BeginFadeGroup(m_ShowMirrorOnBack.faded))
  39. //{
  40. // EditorGUI.indentLevel++;
  41. // ShowProp(materialEditor, FindProperty("_MirrorOnBack", props));
  42. // EditorGUI.indentLevel--;
  43. //}
  44. //EditorGUILayout.EndFadeGroup();
  45. //// Show 3D settings if VR support is enabled on ANY platform.
  46. //m_Show3DControl.value = false;
  47. //foreach (BuildPlatform cur in BuildPlatforms.instance.buildPlatforms)
  48. //{
  49. // if (UnityEditorInternal.VR.VREditor.GetVREnabledOnTargetGroup(cur.targetGroup))
  50. // {
  51. // m_Show3DControl.value = true;
  52. // break;
  53. // }
  54. //}
  55. //if (EditorGUILayout.BeginFadeGroup(m_Show3DControl.faded))
  56. // ShowProp(materialEditor, FindProperty("_Layout", props));
  57. // EditorGUILayout.EndFadeGroup();
  58. //}
  59. //EditorGUILayout.EndFadeGroup();
  60. // Let the default implementation add the extra shader properties at the bottom.
  61. materialEditor.PropertiesDefaultGUI(new MaterialProperty[0]);
  62. }
  63. private float ShowProp(MaterialEditor materialEditor, MaterialProperty prop)
  64. {
  65. materialEditor.ShaderProperty(prop, prop.displayName);
  66. return prop.floatValue;
  67. }
  68. }
  69. }