using System; using UnityEditor; using UnityEngine; namespace Ubisoft { public class HtUnityEditorFactory { public static ScriptableObject CreateScriptableObject(Type t, string unityPath, string name) { ScriptableObject asset = ScriptableObject.CreateInstance(t); if (unityPath == "") { unityPath = "Assets"; } if (!HtAssetDatabase.ExistsFolder(unityPath)) { HtAssetDatabase.CreateFolder(unityPath); } unityPath = HtAssetDatabase.UnityPathCombine(unityPath, name + ".asset"); string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(unityPath); AssetDatabase.CreateAsset(asset, assetPathAndName); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); return asset; } } }