public static T GetOrCreateSettings <T>() where T : ThunderKitSetting { string assetPath = $"Assets/ThunderKitSettings/{typeof(T).Name}.asset"; Directory.CreateDirectory(Path.GetDirectoryName(assetPath)); return(ScriptableHelper.EnsureAsset <T>(assetPath, settings => settings.Initialize())); }
public HMSIAPProductListSettings() { loadedSettings = ScriptableHelper.Load <SettingsScriptableObject>(SettingsFilename, "Assets/Huawei/Settings/Resources"); Debug.Assert(loadedSettings != null, "Failed to load the " + SettingsFilename); _settings = loadedSettings.settings; _settings.OnDictionaryChanged += _settings_OnDictionaryChanged; }
private static void ThunderstoreAPI_PagesLoaded(object sender, System.EventArgs e) { ThunderstoreAPI.PagesLoaded -= ThunderstoreAPI_PagesLoaded; var tss = ScriptableHelper.EnsureAsset <ThunderstoreSource>(CachePath, source => { source.hideFlags = UnityEngine.HideFlags.NotEditable; }); tss.LoadPackages(); }
private static void PackageSource_InitializeSources(object sender, System.EventArgs e) { AssetDatabase.DeleteAsset(CachePath); ThunderstoreAPI.ReloadPages(); var tss = ScriptableHelper.EnsureAsset <ThunderstoreSource>(CachePath, source => { source.hideFlags = UnityEngine.HideFlags.NotEditable; }); tss.LoadPackages(); EditorUtility.SetDirty(tss); AssetDatabase.SaveAssets(); }
public static void Create() { var isNew = false; var source = ScriptableHelper.EnsureAsset <LocalThunderstoreSource>(CachePath, so => { isNew = true; }); if (isNew) { EditorUtility.SetDirty(source); AssetDatabase.SaveAssets(); } }
public static void Initialize() { AssetDatabase.DeleteAsset(CachePath); ThunderstoreAPI.ReloadPages(); var isNew = false; var source = ScriptableHelper.EnsureAsset <ThunderstoreSource>(CachePath, so => { isNew = true; }); if (isNew) { source.hideFlags = UnityEngine.HideFlags.NotEditable; source.LoadPackages(); //EditorApplication.update += ProcessDownloads; } }
public static async Task Initialize() { await ThunderstoreAPI.ReloadPages(); var isNew = false; var source = ScriptableHelper.EnsureAsset <ThunderstoreSource>(CachePath, so => { isNew = true; }); if (isNew) { source.LoadPackages(); source.hideFlags = UnityEngine.HideFlags.NotEditable; EditorUtility.SetDirty(source); AssetDatabase.SaveAssets(); } }
public static void Create() => ScriptableHelper.SelectNewAsset <Pipeline>();
public static void CreateCustomSceneProxy() => ScriptableHelper.CreateAsset <SceneDefinition>();
public static void CreateSceneDefReference() => ScriptableHelper.CreateAsset <SceneDefReference>();
public static void CreateBodySpawnCard() => ScriptableHelper.CreateAsset <BodySpawnCard>();
public static void CreateComposableManifestPipeline() => ScriptableHelper.SelectNewAsset <Pipeline>();
public static void CreateInteractableSpawnCard() => ScriptableHelper.CreateAsset <InteractableSpawnCard>();
public void Save() { ScriptableHelper.Save(this); }
public static void CreateDirectorCardCategorySelection() => ScriptableHelper.CreateAsset <DirectorCardCategorySelection>();
public static void CreateSurfaceDef() => ScriptableHelper.CreateAsset <SurfaceDef>();
public static void CreateBakeSettings() => ScriptableHelper.CreateAsset <BakeSettings>();
public void InstallPackage(PackageGroup group, string version) { if (EditorApplication.isCompiling) { return; } var package = group[version]; var installSet = EnumerateDependencies(package).Where(dep => !dep.group.Installed).ToArray(); var progress = 0.01f; var stepSize = 0.33f / installSet.Length; //Wait till all files are put in place to load new assemblies to make installation more consistent and faster EditorApplication.LockReloadAssemblies(); EditorUtility.DisplayProgressBar("Loading Packages", $"{installSet.Length} packages", progress); foreach (var installable in installSet) { EditorUtility.DisplayProgressBar("Loading Packages", $"Downloading {installable.group.PackageName}", progress += stepSize / 2); //This will cause repeated installation of dependencies string packageDirectory = installable.group.InstallDirectory; if (Directory.Exists(packageDirectory)) { Directory.Delete(packageDirectory, true); } Directory.CreateDirectory(packageDirectory); installable.group.Source.OnInstallPackageFiles(installable, packageDirectory); foreach (var assemblyPath in Directory.GetFiles(packageDirectory, "*.dll", SearchOption.AllDirectories)) { PackageHelper.WriteAssemblyMetaData(assemblyPath, $"{assemblyPath}.meta"); } EditorUtility.DisplayProgressBar("Loading Packages", $"Creating package.json for {installable.group.PackageName}", progress += stepSize / 2); PackageHelper.GeneratePackageManifest( installable.group.DependencyId.ToLower(), installable.group.InstallDirectory, installable.group.PackageName, installable.group.Author, installable.version, installable.group.Description); } AssetDatabase.SaveAssets(); //Refresh here to update the AssetDatabase so that it can manage the creation of Manifests in the packages via the Unity Package path notation //e.g Packages/com.passivepicasso.thunderkit/Editor AssetDatabase.Refresh(); EditorUtility.DisplayProgressBar("Loading Packages", $"Creating {installSet.Length} manifests", progress); foreach (var installable in installSet) { var installableGroup = installable.group; var manifestPath = PathExtensions.Combine(installableGroup.PackageDirectory, $"{installableGroup.PackageName}.asset"); if (AssetDatabase.LoadAssetAtPath <Manifest>(manifestPath)) { AssetDatabase.DeleteAsset(manifestPath); } EditorUtility.DisplayProgressBar("Loading Packages", $"Creating manifest for {installable.group.PackageName}", progress += stepSize); var identity = CreateInstance <ManifestIdentity>(); identity.name = nameof(ManifestIdentity); identity.Author = installableGroup.Author; identity.Description = installableGroup.Description; identity.Name = installableGroup.PackageName; identity.Version = version; var manifest = ScriptableHelper.EnsureAsset <Manifest>(manifestPath); manifest.InsertElement(identity, 0); manifest.Identity = identity; PackageHelper.WriteAssetMetaData(manifestPath); } //Refresh here to update the AssetDatabase's representation of the Assets with ThunderKit managed Meta files AssetDatabase.Refresh(); EditorUtility.DisplayProgressBar("Loading Packages", $"Assigning dependencies for {installSet.Length} manifests", progress); foreach (var installable in installSet) { var manifestPath = PathExtensions.Combine(installable.group.PackageDirectory, $"{installable.group.PackageName}.asset"); var installableManifest = AssetDatabase.LoadAssetAtPath <Manifest>(manifestPath); var identity = installableManifest.Identity; EditorUtility.DisplayProgressBar("Loading Packages", $"Assigning dependencies for {installable.group.PackageName}", progress); identity.Dependencies = new Manifest[installable.dependencies.Length]; for (int i = 0; i < installable.dependencies.Length; i++) { var installableDependency = installable.dependencies[i]; EditorUtility.DisplayProgressBar("Loading Packages", $"Assigning {installableDependency.group.PackageName} to {identity.Name}", progress += stepSize / installable.dependencies.Length); var manifestFileName = $"{installableDependency.group.PackageName}.asset"; var dependencyAssetTempPath = PathExtensions.Combine(installableDependency.group.PackageDirectory, manifestFileName); var manifest = AssetDatabase.LoadAssetAtPath <Manifest>(dependencyAssetTempPath); if (!manifest) { var packageManifests = AssetDatabase.FindAssets($"t:{nameof(Manifest)}", new string[] { "Assets", "Packages" }).Select(x => AssetDatabase.GUIDToAssetPath(x)).ToArray(); manifest = packageManifests.Where(x => x.Contains(manifestFileName)).Select(x => AssetDatabase.LoadAssetAtPath <Manifest>(x)).FirstOrDefault(); } identity.Dependencies[i] = manifest; } EditorUtility.SetDirty(installable); EditorUtility.SetDirty(identity); } EditorUtility.ClearProgressBar(); AssetDatabase.SaveAssets(); EditorApplication.update += OneRefresh; RefreshWait = EditorApplication.timeSinceStartup; EditorApplication.UnlockReloadAssemblies(); }
//填充3c场景 static void FillScnData3C(string scnType, string scnName, string scnSubFolderPath, GameObject scnPrefab) { var trm = scnPrefab.transform; var mapTrm = trm.GetChild(0); string mapName = mapTrm.name; var objsTrm = trm.Find("objs"); Tower[] towers = objsTrm.GetComponentsInChildren <Tower> (); //获取或创建ScnData string scnDataAssetPath = scnSubFolderPath + "/scnData.asset"; //Debug.LogError ("------>scnDataAssetPath:"+scnDataAssetPath); string scnDataAssetReletivePath = EditorHelper.ChangeToRelativePath(scnDataAssetPath); Scn3CData scn3CData = new Scn3CData(); scn3CData.ScnName = scnName; scn3CData.MapName = mapName; scn3CData.TowerDataList = new List <TowerData> (); for (int i = 0; i < towers.Length; i++) { TowerData td = new TowerData(); td.Camp = towers[i].Camp; td.Pos = towers [i].transform.position; td.Priority = towers [i].Priority; scn3CData.TowerDataList.Add(td); } Town[] towns = objsTrm.GetComponentsInChildren <Town> (); scn3CData.TownDataList = new List <TownData> (); for (int i = 0; i < towns.Length; i++) { TownData td = new TownData(); td.Camp = towns[i].Camp; td.Pos = towns [i].transform.position; scn3CData.TownDataList.Add(td); } if (!EditorHelper.BeFileExist(scnDataAssetPath)) { Debug.LogError("MeEditor.FillScnData3C scnData 不存在,创建新数据文件 path:" + scnDataAssetPath + " "); scn3CData = ScriptableHelper.CreateOrReplaceAsset <Scn3CData> (scn3CData, scnDataAssetReletivePath); } else { Scn3CData oldScn3CData = AssetDatabase.LoadAssetAtPath <Scn3CData> (scnDataAssetReletivePath); bool bSame = Scn3CData.BeSame(scn3CData, oldScn3CData); Debug.LogError("MeEditor.FillScnData3C scnData存在,读取数据文件,判断是否有数据变更,有就覆盖数据 path:" + scnDataAssetPath + " bSame:" + bSame); if (!bSame) { oldScn3CData.ScnName = scn3CData.ScnName; oldScn3CData.MapName = scn3CData.MapName; oldScn3CData.TowerDataList = new List <TowerData> (); oldScn3CData.TowerDataList.AddRange(scn3CData.TowerDataList.ToArray()); oldScn3CData.TownDataList = new List <TownData> (); oldScn3CData.TownDataList.AddRange(scn3CData.TownDataList.ToArray()); Debug.LogError("MeEditor.FillScnData3C scnName:" + oldScn3CData.ScnName + " mapName:" + oldScn3CData.MapName + " ListCount:" + oldScn3CData.TowerDataList.Count); } } }
public static void CreateCharacterSpawnCard() => ScriptableHelper.CreateAsset <CharacterSpawnCard>();
public static void CreateMusicTrackDefRef() => ScriptableHelper.CreateAsset <MusicTrackDefRef>();
public static void Create() => ScriptableHelper.SelectNewAsset <PathReference>();