Ejemplo n.º 1
0
    public static WwiseObjectReference FindOrCreateWwiseObject(WwiseObjectType wwiseObjectType, string name, System.Guid guid)
    {
        var parentPath  = GetParentPath(wwiseObjectType);
        var path        = System.IO.Path.Combine(parentPath, GetAssetFileName(guid));
        var asset       = FindExistingWwiseObject(wwiseObjectType, guid, path);
        var assetExists = asset != null;

        if (!assetExists)
        {
            AkUtilities.CreateFolder(parentPath);
            asset      = Create(wwiseObjectType);
            asset.guid = guid.ToString().ToUpper();
        }

        var changed = UpdateWwiseObjectData(asset, name);

        if (!assetExists)
        {
            UnityEditor.AssetDatabase.CreateAsset(asset, path);
        }
        else if (changed)
        {
            UnityEditor.EditorUtility.SetDirty(asset);
        }

        return(asset);
    }
Ejemplo n.º 2
0
        public static AkWwiseAddressablesInitializationSettings ReplaceOrCreateAsset(string className, string fileName)
        {
            var path        = System.IO.Path.Combine(AkWwiseEditorSettings.WwiseScriptableObjectRelativePath, fileName + ".asset");
            var assetExists = string.IsNullOrEmpty(UnityEditor.AssetDatabase.AssetPathToGUID(path));

            if (assetExists)
            {
                var loadedAsset = UnityEditor.AssetDatabase.LoadAssetAtPath <AkWwiseAddressablesInitializationSettings>(path);
                if (loadedAsset != null)
                {
                    return(loadedAsset);
                }
                else                 //overwrite current InitializationSettings asset with new one adressables one
                {
                    UnityEditor.AssetDatabase.DeleteAsset(path);
                    var newAsset = CreateInstance <AkWwiseAddressablesInitializationSettings>();
                    UnityEditor.AssetDatabase.CreateAsset(newAsset, path);
                    return(newAsset);
                }
            }

            var guids = UnityEditor.AssetDatabase.FindAssets("t:" + typeof(AkWwiseAddressablesInitializationSettings).Name);

            foreach (var assetGuid in guids)
            {
                var assetPath  = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuid);
                var foundAsset = UnityEditor.AssetDatabase.LoadAssetAtPath <AkWwiseAddressablesInitializationSettings>(assetPath);
                if (foundAsset)
                {
                    return(foundAsset);
                }
            }

            var createdAsset = CreateInstance <AkWwiseAddressablesInitializationSettings>();

            AkUtilities.CreateFolder(AkWwiseEditorSettings.WwiseScriptableObjectRelativePath);
            UnityEditor.AssetDatabase.CreateAsset(createdAsset, path);
            return(createdAsset);
        }