public override void OnInspectorGUI() { var asset = target as EffekseerEffectAsset; EditorGUILayout.LabelField("Data Size", asset.efkBytes.Length.ToString() + " bytes"); var scale = EditorGUILayout.FloatField("Scale", asset.Scale); scale = Math.Max(0, scale); if (asset.Scale != scale) { asset.Scale = scale; EditorUtility.SetDirty(asset); } textureVisible = EditorGUILayout.Foldout(textureVisible, "Texture Resources: " + asset.textureResources.Length); if (textureVisible) { EditorGUI.indentLevel++; foreach (var res in asset.textureResources) { if (EffekseerTextureResource.InspectorField(res)) { EditorUtility.SetDirty(asset); } } EditorGUI.indentLevel--; } soundVisible = EditorGUILayout.Foldout(soundVisible, "Sound Resources: " + asset.soundResources.Length); if (soundVisible) { EditorGUI.indentLevel++; foreach (var res in asset.soundResources) { if (EffekseerSoundResource.InspectorField(res)) { EditorUtility.SetDirty(asset); } } EditorGUI.indentLevel--; } modelVisible = EditorGUILayout.Foldout(modelVisible, "Model Resources: " + asset.modelResources.Length); if (modelVisible) { EditorGUI.indentLevel++; foreach (var res in asset.modelResources) { if (EffekseerModelResource.InspectorField(res)) { EditorUtility.SetDirty(asset); } } EditorGUI.indentLevel--; } }
public static void CreateAsset(string path, byte[] data) { EffekseerResourcePath resourcePath = new EffekseerResourcePath(); if (!ReadResourcePath(data, ref resourcePath)) { return; } float defaultScale = 1.0f; string assetPath = Path.ChangeExtension(path, ".asset"); var asset = AssetDatabase.LoadAssetAtPath <EffekseerEffectAsset>(assetPath); if (asset != null) { defaultScale = asset.Scale; } string assetDir = assetPath.Substring(0, assetPath.LastIndexOf('/')); bool isNewAsset = false; if (asset == null) { isNewAsset = true; asset = CreateInstance <EffekseerEffectAsset>(); } asset.efkBytes = data; asset.textureResources = new EffekseerTextureResource[resourcePath.TexturePathList.Count]; for (int i = 0; i < resourcePath.TexturePathList.Count; i++) { asset.textureResources[i] = EffekseerTextureResource.LoadAsset(assetDir, resourcePath.TexturePathList[i]); } asset.soundResources = new EffekseerSoundResource[resourcePath.SoundPathList.Count]; for (int i = 0; i < resourcePath.SoundPathList.Count; i++) { asset.soundResources[i] = EffekseerSoundResource.LoadAsset(assetDir, resourcePath.SoundPathList[i]); } asset.modelResources = new EffekseerModelResource[resourcePath.ModelPathList.Count]; for (int i = 0; i < resourcePath.ModelPathList.Count; i++) { asset.modelResources[i] = EffekseerModelResource.LoadAsset(assetDir, resourcePath.ModelPathList[i]); } asset.Scale = defaultScale; if (isNewAsset) { AssetDatabase.CreateAsset(asset, assetPath); } else { EditorUtility.SetDirty(asset); } AssetDatabase.Refresh(); }