PackPlatformDrawers.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. namespace Pack
  6. {
  7. [CustomPropertyDrawer(typeof(PackPlatformBase))]
  8. public class PackPlatformBaseDrawers : PropertyDrawer
  9. {
  10. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  11. {
  12. position = DrawChildPropertyField(position, property, "channelUniqueName", "渠道唯一名字", "唯一名字(只能使用数字,英文,英文符号)");
  13. position = DrawChildPropertyField(position, property, "channelName", "渠道名字");
  14. position = DrawChildPropertyField(position, property, "appName", "游戏名");
  15. position = DrawChildPropertyField(position, property, "buildTarget", "目标编译平台");
  16. position = DrawChildPropertyField(position, property, "bundleId");
  17. // position = DrawChildPropertyField(position, property, "defineSymbols", "编译宏");
  18. // position = DrawChildPropertyField(position, property, "platformName", "目标包名");
  19. // position = DrawChildPropertyField(position, property, "platformName", "目标包名");
  20. // position = DrawChildPropertyField(position, property, "platformName", "目标包名");
  21. }
  22. public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
  23. {
  24. return base.GetPropertyHeight(property, label);
  25. }
  26. protected Rect DrawDefineSymbolsPropertyField(Rect position, SerializedProperty property, string name, string title = "", string tooltip = "")
  27. {
  28. SerializedProperty platformName = property.FindPropertyRelative(name);
  29. if (platformName != null)
  30. {
  31. // EditorGUI.BeginProperty(position, EditorGUIUtility.TrTextContent((string.IsNullOrEmpty(title) ? name : title), tooltip), platformName);
  32. // EditorGUI.BeginChangeCheck();
  33. // if (EditorGUI.EndChangeCheck())
  34. // m_Property.constantMax.floatValue = newConstantMax;
  35. // EditorGUI.PropertyField(position, platformName, EditorGUIUtility.TrTextContent((string.IsNullOrEmpty(title) ? name : title), tooltip));
  36. position = OffsetLineHeight(position);
  37. }
  38. return position;
  39. }
  40. protected Rect DrawChildPropertyField(Rect position, SerializedProperty property, string name, string title = "", string tooltip = "")
  41. {
  42. SerializedProperty platformName = property.FindPropertyRelative(name);
  43. if (platformName != null)
  44. {
  45. EditorGUI.PropertyField(position, platformName, EditorGUIUtility.TrTextContent((string.IsNullOrEmpty(title) ? name : title), tooltip));
  46. position = OffsetLineHeight(position);
  47. }
  48. return position;
  49. }
  50. protected Rect OffsetLineHeight(Rect position)
  51. {
  52. position.y += 16;
  53. position.height = position.height - 16;
  54. return position;
  55. }
  56. }
  57. [CustomPropertyDrawer(typeof(PackPlatformPC))]
  58. public class PackPlatformPCDrawers : PackPlatformBaseDrawers
  59. {
  60. }
  61. [CustomPropertyDrawer(typeof(PackPlatformAndroid))]
  62. public class PackPlatformAndroidDrawers : PackPlatformBaseDrawers
  63. {
  64. }
  65. [CustomPropertyDrawer(typeof(PackPlatformPC))]
  66. public class PackPlatformiOSDrawers : PackPlatformBaseDrawers
  67. {
  68. }
  69. }