ScrollPanelInspector.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEditor;
  2. [CustomEditor(typeof(JC.ScrollPanel))]
  3. public class ScrollPanelInspector : Editor
  4. {
  5. private JC.ScrollPanel scrollPanel;
  6. private SerializedProperty initType,startIndex, spacing, openReceiveItemViewInfo, onReceiveItemViewInfo, prefabs , offset;
  7. void OnEnable()
  8. {
  9. scrollPanel = target as JC.ScrollPanel;
  10. initType = serializedObject.FindProperty("initType");
  11. startIndex = serializedObject.FindProperty("startIndex");
  12. spacing = serializedObject.FindProperty("spacing");
  13. offset = serializedObject.FindProperty("offset");
  14. openReceiveItemViewInfo = serializedObject.FindProperty("openReceiveItemViewInfo");
  15. onReceiveItemViewInfo = serializedObject.FindProperty("onReceiveItemViewInfo");
  16. prefabs = serializedObject.FindProperty("prefabs");
  17. }
  18. public override void OnInspectorGUI()
  19. {
  20. serializedObject.Update();
  21. EditorGUILayout.PropertyField(initType);
  22. EditorGUILayout.PropertyField(startIndex);
  23. EditorGUILayout.PropertyField(spacing);
  24. EditorGUILayout.PropertyField(offset);
  25. EditorGUILayout.PropertyField(openReceiveItemViewInfo);
  26. if (scrollPanel.openReceiveItemViewInfo) {
  27. EditorGUILayout.PropertyField(onReceiveItemViewInfo);
  28. }
  29. EditorGUILayout.PropertyField(prefabs);
  30. serializedObject.ApplyModifiedProperties();
  31. PrefabUtility.RecordPrefabInstancePropertyModifications(scrollPanel);
  32. }
  33. }