WeaponAttachmentHelperEditor.cs 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. using UnityEditor.SceneManagement;
  6. namespace FiradzoAssets
  7. {
  8. [CustomEditor(typeof(WeaponAttachmentHelper))]
  9. public class WeaponAttachmentHelperEditor : Editor
  10. {
  11. public override void OnInspectorGUI()
  12. {
  13. var targetComponent = (target as WeaponAttachmentHelper);
  14. var canRebind = true;
  15. if (!EditorSceneManager.IsPreviewScene(targetComponent.gameObject.scene) && PrefabUtility.IsPartOfPrefabInstance(targetComponent.gameObject))
  16. {
  17. EditorGUILayout.HelpBox("Component will not work on prefab instance on scene in edit mode. You can unpack prefab or enter prefab edit mode by clicking 'Open' button.", MessageType.Warning);
  18. canRebind = false;
  19. }
  20. GUILayout.Space(10f);
  21. base.OnInspectorGUI();
  22. if (canRebind)
  23. {
  24. targetComponent.TryRefreshBindedItems();
  25. }
  26. }
  27. }
  28. }