///////////// // ASSETS /// ///////////// void AddAssetsFromSelection() { int previousAssetCount = currentConfiguration.assets.Count; Object[] audioSelection = Selection.GetFiltered(typeof(AudioClip), SelectionMode.Assets); Object[] textureSelection = Selection.GetFiltered(typeof(Texture2D), SelectionMode.Assets); for (int i = 0; i < audioSelection.Length; i++) { AudioClip clip = audioSelection[i] as AudioClip; string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(clip)); //If the asset doesn't already exist on the assets list, add it if (!currentConfiguration.assets.Exists(x => x.guid == guid)) { AudioAsset audioAsset = new AudioAsset(); audioAsset.ReadFromAsset(clip); currentConfiguration.assets.Add(audioAsset); } else { Debug.Log("Asset " + clip.name + " already exists in the " + currentConfiguration.name + " configuration at path: " + AssetDatabase.GUIDToAssetPath(guid)); } } for (int i = 0; i < textureSelection.Length; i++) { Texture2D texture = textureSelection[i] as Texture2D; string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(texture)); //If the asset doesn't already exist on the assets list, add it if (!currentConfiguration.assets.Exists(x => x.guid == guid)) { TextureAsset textureAsset = new TextureAsset(); textureAsset.ReadFromAsset(texture); currentConfiguration.assets.Add(textureAsset); } else { Debug.Log("Asset " + texture.name + " already exists in the " + currentConfiguration.name + " configuration at path: " + AssetDatabase.GUIDToAssetPath(guid)); } } //If assets got added, select the first asset that was added if (currentConfiguration.assets.Count > previousAssetCount) { WriteToFile(); AssetIndex = previousAssetCount; } else { Debug.Log("No new audio or texture assets were added to the " + currentConfiguration.name + " configuration."); } }
///////////// // ASSETS /// ///////////// void AddAssetsFromSelection() { int previousAssetCount = currentConfiguration.assets.Count; Object[] audioSelection = Selection.GetFiltered(typeof(AudioClip), SelectionMode.Assets); Object[] textureSelection = Selection.GetFiltered(typeof(Texture2D), SelectionMode.Assets); for(int i=0; i<audioSelection.Length; i++) { AudioClip clip = audioSelection[i] as AudioClip; string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(clip)); //If the asset doesn't already exist on the assets list, add it if(!currentConfiguration.assets.Exists(x => x.guid == guid)) { AudioAsset audioAsset = new AudioAsset(); audioAsset.ReadFromAsset(clip); currentConfiguration.assets.Add(audioAsset); } else { Debug.Log("Asset " + clip.name + " already exists in the " + currentConfiguration.name + " configuration at path: " + AssetDatabase.GUIDToAssetPath(guid)); } } for(int i=0; i<textureSelection.Length; i++) { Texture2D texture = textureSelection[i] as Texture2D; string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(texture)); //If the asset doesn't already exist on the assets list, add it if(!currentConfiguration.assets.Exists(x => x.guid == guid)) { TextureAsset textureAsset = new TextureAsset(); textureAsset.ReadFromAsset(texture); currentConfiguration.assets.Add(textureAsset); } else { Debug.Log("Asset " + texture.name + " already exists in the " + currentConfiguration.name + " configuration at path: " + AssetDatabase.GUIDToAssetPath(guid)); } } //If assets got added, select the first asset that was added if(currentConfiguration.assets.Count > previousAssetCount) { WriteToFile(); AssetIndex = previousAssetCount; } else { Debug.Log("No new audio or texture assets were added to the " + currentConfiguration.name + " configuration."); } }