MenuBase.cs 836 B

12345678910111213141516171819202122
  1. using UnityEngine;
  2. using UnityEditor;
  3. namespace SC.Menu {
  4. public abstract class MenuBase : MonoBehaviour {
  5. protected static void CreatePrefab(string ResourcesPath) {
  6. GameObject go = (GameObject)PrefabUtility.InstantiatePrefab(Resources.Load(ResourcesPath));
  7. if(go) {
  8. GameObjectUtility.SetParentAndAlign(go, Selection.activeTransform == null ? null : Selection.activeTransform.gameObject);
  9. go.transform.SetParent(Selection.activeTransform);
  10. Undo.RegisterCreatedObjectUndo(go, go.name);
  11. Selection.activeTransform = go.transform;
  12. //Debug.Log("Create Sucess ! Prefab:" + ResourcesPath);
  13. } else {
  14. //Debug.LogError("Create Failed ! Prefab:" + ResourcesPath);
  15. }
  16. }
  17. }
  18. }