少年修仙传客户端基础资源
dabaoji
2025-06-09 8ee0256378cbf5dbc9d76ed10b60b65a844ef4dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
 
public static class ApplyHelper
{
 
    [MenuItem("Edit/ApplyHelper %q", false, 1)]
    static void ApplySelected()
    {
        var selectedsGameobject = Selection.gameObjects;
        for (int i = 0; i < selectedsGameobject.Length; i++)
        {
            var obj = selectedsGameobject[i];
            var root = PrefabUtility.FindPrefabRoot(obj);
            if (PrefabUtility.GetPrefabType(root) == PrefabType.PrefabInstance)
            {
                var parentObject = PrefabUtility.GetPrefabParent(root);
                PrefabUtility.ReplacePrefab(root, parentObject, ReplacePrefabOptions.ConnectToPrefab);
            }
        }
 
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
 
}