|
| 1 | +using ReadyPlayerMe.Core.Editor; |
1 | 2 | using UnityEditor; |
2 | 3 | using UnityEngine; |
3 | 4 |
|
4 | 5 | namespace ReadyPlayerMe.NetcodeSupport.Editor |
5 | 6 | { |
6 | 7 | public static class TransferPrefab |
7 | 8 | { |
8 | | - [MenuItem("Ready Player Me/Transfer Netcode Prefab")] |
| 9 | + private const string NEW_PREFAB_PATH = "Assets/Ready Player Me/Resources/RPM_Netcode_Character.prefab"; |
| 10 | + private const string PREFAB_ASSET_NAME = "t:prefab RPM_Netcode_Character"; |
| 11 | + |
| 12 | + [MenuItem("Ready Player Me/Transfer Netcode Prefab", priority = 34)] |
9 | 13 | public static void Transfer() |
10 | 14 | { |
11 | | - string[] guids = AssetDatabase.FindAssets("t:prefab RPM_Netcode_Character"); |
| 15 | + var guids = AssetDatabase.FindAssets(PREFAB_ASSET_NAME); |
12 | 16 |
|
13 | 17 | if (guids.Length == 0) |
14 | 18 | { |
15 | 19 | Debug.Log("RPM_Netcode_Character prefab not found. Please reimport Netcode Support package."); |
16 | 20 | } |
17 | 21 | else |
18 | 22 | { |
19 | | - if (AssetDatabase.LoadAssetAtPath("Assets/Ready Player Me/Resources/RPM_Character.prefab", typeof(GameObject))) |
| 23 | + if (AssetDatabase.LoadAssetAtPath(NEW_PREFAB_PATH, typeof(GameObject))) |
20 | 24 | { |
21 | | - if (!EditorUtility.DisplayDialog("Warning", "RPM_Character prefab already exists. Do you want to overwrite it?", "Yes", "No")) |
| 25 | + if (!EditorUtility.DisplayDialog("Warning", "RPM_Netcode_Character prefab already exists. Do you want to overwrite it?", "Yes", "No")) |
22 | 26 | { |
23 | 27 | return; |
24 | 28 | } |
25 | 29 | } |
26 | | - |
27 | | - string path = AssetDatabase.GUIDToAssetPath(guids[0]); |
28 | | - AssetDatabase.CopyAsset(path, "Assets/Ready Player Me/Resources/RPM_Character.prefab"); |
29 | | - Selection.activeObject = AssetDatabase.LoadAssetAtPath("Assets/Ready Player Me/Resources/RPM_Character.prefab", typeof(GameObject)); |
30 | | - Debug.Log("Netcode prefab transferred to Assets/Ready Player Me/Resources/RPM_Character.prefab"); |
| 30 | + PrefabHelper.TransferPrefabByGuid(guids[0], NEW_PREFAB_PATH); |
| 31 | + Debug.Log($"Netcode prefab transferred to {NEW_PREFAB_PATH}"); |
31 | 32 | } |
32 | 33 | } |
33 | 34 | } |
|
0 commit comments