コード例 #1
0
        public static void CreateOfflineData(GameObject Obj)
        {
            OfflineData offlineData = Obj.GetComponent <OfflineData>();

            if (offlineData is null)
            {
                offlineData = Obj.AddComponent <OfflineData>();
            }
            offlineData.BindDataInEditor();
            EditorUtility.SetDirty(Obj); // 保存
            Debug.Log("修改了" + Obj.name + " prefab!");
        }
コード例 #2
0
        public static void CreateOfflineUIData(GameObject obj)
        {
            obj.layer = LayerMask.NameToLayer("UI");
            OfflineData uiData = obj.GetComponent <OfflineUIData>();

            if (uiData is null)
            {
                uiData = obj.AddComponent <OfflineUIData>();
            }
            uiData.BindDataInEditor();
            EditorUtility.SetDirty(obj);
            Debug.Log("修改了" + obj.name + "UI Prefab!");
            Resources.UnloadUnusedAssets();
            AssetDatabase.Refresh();
        }