private void GenerateDicingTexture(DicingTexture target) { var exportPath = string.Empty; var textures = textureInfos .Where(x => x.status == TextureStatus.Exist || x.status == TextureStatus.Add || x.status == TextureStatus.Update) .Where(x => !deleteNames.Contains(x.texture.name)) .Select(x => x.texture) .ToArray(); if (target == null) { var path = string.Empty; if (string.IsNullOrEmpty(Prefs.exportPath) || !Directory.Exists(path)) { path = UnityPathUtility.AssetsFolder; } else { path = Prefs.exportPath; } exportPath = EditorUtility.SaveFilePanelInProject("Save As", "New DicingTexture.asset", "asset", "Save as...", path); } else { exportPath = AssetDatabase.GetAssetPath(target); } if (!string.IsNullOrEmpty(exportPath)) { var dicingData = generator.Generate(exportPath, blockSize, padding, textures, hasAlphaMap); target = ScriptableObjectGenerator.Generate <DicingTexture>(exportPath); target.Set(dicingData.Texture, blockSize, padding, dicingData.SourceTextures, dicingData.DicingBlocks, hasAlphaMap); target.Texture.filterMode = filterMode; UnityEditorUtility.SaveAsset(target); Prefs.exportPath = exportPath; selectDicingTexture = target; BuildTextureInfos(); deleteNames.Clear(); Repaint(); } }
private static void Generate() { var selectedObject = Selection.activeObject.name; var selectedType = Type.GetType(selectedObject + "," + typeof(ReferenceScript).Assembly); if (selectedType.IsInterface) { ScriptableObjectGenerator.Create(selectedType); } else { Debug.LogError("Can only create Scriptable Objects from interfaces"); } }
private static TextDataAsset LoadAsset(string assetPath) { if (string.IsNullOrEmpty(assetPath)) { return(null); } var asset = AssetDatabase.LoadMainAssetAtPath(assetPath) as TextDataAsset; if (asset == null) { asset = ScriptableObjectGenerator.Generate <TextDataAsset>(assetPath); } return(asset); }
private static GameTextAsset LoadAsset(string assetFolderPath, string resourcesPath) { var assetPath = PathUtility.Combine(assetFolderPath, resourcesPath); if (string.IsNullOrEmpty(assetPath)) { return(null); } var asset = AssetDatabase.LoadAssetAtPath <GameTextAsset>(assetPath); if (asset == null) { asset = ScriptableObjectGenerator.Generate <GameTextAsset>(assetPath); } return(asset); }
private bool CreateBehaviorDataAsset(string assetPath, TBehaviorData behaviorData, DateTime lastUpdate) { var behaviorControlAsset = ScriptableObjectGenerator.Generate <BehaviorControlAsset>(assetPath, false); if (behaviorControlAsset == null) { return(false); } var behaviors = new List <BehaviorControlAsset.Behavior>(); foreach (var b in behaviorData.Behaviors) { var conditions = new List <BehaviorControlAsset.Condition>(); foreach (var c in b.Conditions) { var conditionType = GetEnumName(c.Type); var conditionParameters = c.Parameters; var connecter = c.Connecter; var condition = new BehaviorControlAsset.Condition(conditionType, conditionParameters, connecter); conditions.Add(condition); } var successRate = b.SuccessRate; var actionType = GetEnumName(b.ActionType); var actionParameters = b.ActionParameters; var targetType = GetEnumName(b.TargetType); var targetParameters = b.TargetParameters; var behavior = new BehaviorControlAsset.Behavior(successRate, actionType, actionParameters, targetType, targetParameters, conditions.ToArray()); behaviors.Add(behavior); } behaviorControlAsset.Set(behaviorData.Description, behaviors.ToArray(), lastUpdate); UnityEditorUtility.SaveAsset(behaviorControlAsset); return(true); }
private static AssetInfoManifest GenerateManifest(AssetManageManager assetManageManager) { // アセット情報を収集. assetManageManager.CollectInfo(); var allAssetInfos = assetManageManager.GetAllAssetInfos().ToArray(); // アセット情報を更新. var manifestPath = GetManifestPath(assetManageManager.ExternalResourcesPath); var manifest = ScriptableObjectGenerator.Generate <AssetInfoManifest>(manifestPath); Reflection.SetPrivateField(manifest, "assetInfos", allAssetInfos); UnityEditorUtility.SaveAsset(manifest); // アセットバンドル名設定. var importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(manifest)); importer.assetBundleName = AssetInfoManifest.AssetBundleName; importer.SaveAndReimport(); return(manifest); }
public static void GenerateScriptableObject() { ScriptableObjectGenerator.Generate(); }
private void GeneratePatternTexture(PatternTexture patternTexture) { if (textureInfos == null) { Debug.LogError("Require select texture."); return; } var exportPath = string.Empty; var textures = textureInfos .Where(x => x.status == TextureStatus.Exist || x.status == TextureStatus.Add || x.status == TextureStatus.Update) .Where(x => !deleteNames.Contains(x.texture.name)) .Select(x => x.texture) .ToArray(); if (patternTexture == null) { var path = string.Empty; var savedExportPath = Prefs.exportPath; if (string.IsNullOrEmpty(savedExportPath) || !File.Exists(savedExportPath)) { path = UnityPathUtility.AssetsFolder; } else { var directory = Directory.GetParent(savedExportPath); path = directory.FullName; } exportPath = EditorUtility.SaveFilePanelInProject("Save As", "New PatternTexture.asset", "asset", "Save as...", path); } else { exportPath = AssetDatabase.GetAssetPath(patternTexture); } if (!string.IsNullOrEmpty(exportPath)) { patternTexture = ScriptableObjectGenerator.Generate <PatternTexture>(exportPath); var patternData = generator.Generate(exportPath, blockSize, padding, textures, hasAlphaMap); patternTexture.Set(patternData.Texture, blockSize, padding, patternData.PatternData, patternData.PatternBlocks, hasAlphaMap); patternTexture.Texture.filterMode = filterMode; UnityEditorUtility.SaveAsset(patternTexture); Prefs.exportPath = exportPath; selectPatternTexture = patternTexture; var selectionTextures = GetSelectionTextures(); BuildTextureInfos(selectionTextures); deleteNames.Clear(); Repaint(); } }
private void ApplyAtlas(AtlasAction action, List <Texture> textures) { if (action == AtlasAction.None) { return; } StartTextureEdit(selectAtlas, textures); if (action.HasFlag(AtlasAction.Create)) { var path = string.Empty; if (string.IsNullOrEmpty(Prefs.exportPath) || !Directory.Exists(path)) { path = UnityPathUtility.AssetsFolder; } else { path = Prefs.exportPath; } path = EditorUtility.SaveFilePanelInProject("Save As", "New Atlas.asset", "asset", "Save atlas as...", path); if (!string.IsNullOrEmpty(path)) { Prefs.exportPath = Path.GetDirectoryName(path) + PathUtility.PathSeparator; // Create ScriptableObject for atlas. var atlasTexture = ScriptableObjectGenerator.Generate <AtlasTexture>(path, false); if (atlasTexture != null) { Selection.activeObject = atlasTexture; OnSelectAtlas(atlasTexture); } } else { action = AtlasAction.None; } } else if (action.HasFlag(AtlasAction.Delete)) { var sprites = new List <SpriteEntry>(); ExtractSprites(selectAtlas, sprites); for (int i = sprites.Count; i > 0;) { var ent = sprites[--i]; if (deleteNames.Contains(ent.name)) { sprites.RemoveAt(i); } } UpdateAtlas(selectAtlas, sprites); deleteNames.Clear(); } if (action.HasFlag(AtlasAction.Update)) { UpdateAtlas(selectAtlas, textures, true); } else if (action.HasFlag(AtlasAction.Replace)) { UpdateAtlas(selectAtlas, textures, false); } selectAtlas.CacheClear(); FinishTextureEdit(); UnityEditorUtility.SaveAsset(selectAtlas); }