Placeholder-Software / Dissonance

Unity Voice Chat Asset
71 stars 5 forks source link

Dissonance cannot be moved out of Assets/Plugins/Dissonance #51

Closed TobiasWehrum closed 7 years ago

TobiasWehrum commented 7 years ago

Since we're using a lot of assets/plugins, we don't have any assets/plugins on the top level. Dissonance cannot deal with that since it references the Assets/Plugins/Dissonance path in multiple files (which we have to edit by hand every time we update Dissonance).

The files are the following (Dissonance 3.0.0):

I think the best way to fix this is to save the path in a ScriptableObject and show a dialog box to edit the path if Dissonance detects that the current path is not available.

martindevans commented 7 years ago

Hi Tobias,

That's probably a good idea. I've got a few bug investigations in progress at the moment which take higher priority but I'll see if I can find some time to look into it when I'm waiting for feedback.

Out of interest, how do you arrange your plugins?

TobiasWehrum commented 7 years ago

Hi Martin,

By all means, tackle any bugs first - this is a fairly low effort for us, it's just annyoing. Maybe (as an easy first step) you could make a global static path string so that we just have to change one file on update?

Usually we just put every extension into a folder Assets/Extensions. For this project, we have independent modules, so it's Assets/ModuleName/Extensions.

martindevans commented 7 years ago

I got to this a bit quicker than expected! I've put together a class which locates itself and that acts as a base path for all the other paths Dissonance uses. If you'd like to test it:

instructions went here

Edit; That's what I get for rushing things - this doesn't quite work. Give me a few more minutes!

TobiasWehrum commented 7 years ago

I'm getting these two DebugLog.Errors (and two more for DebugSettings):

.ctor is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'VoiceSettings'. See "Script Serialization" page in the Unity Manual for further details. UnityEditor.AssetDatabase:FindAssets(String) Dissonance.DissonanceResourceLocator:get_BaseLocation() (at Assets/ImmersiveDeck/Dependencies/Dissonance/Ressources/DissonanceResourceLocator.cs:23) Dissonance.DissonanceResourceLocator:GetPathForAsset(String) (at Assets/ImmersiveDeck/Dependencies/Dissonance/Ressources/DissonanceResourceLocator.cs:37) Dissonance.Config.VoiceSettings:.cctor() (at Assets/ImmersiveDeck/Dependencies/Dissonance/Plugins/Dissonance/Core/Config/VoiceSettings.cs:25)

UnityException: .ctor is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'VoiceSettings'. See "Script Serialization" page in the Unity Manual for further details. UnityEditor.AssetDatabase.SearchAllAssets (UnityEditor.SearchFilter searchFilter) (at C:/buildslave/unity/build/Editor/Mono/AssetDatabaseSearching.cs:33) UnityEditor.AssetDatabase.FindAssets (UnityEditor.SearchFilter searchFilter) (at C:/buildslave/unity/build/Editor/Mono/AssetDatabaseSearching.cs:28) UnityEditor.AssetDatabase.FindAssets (System.String filter, System.String[] searchInFolders) (at C:/buildslave/unity/build/Editor/Mono/AssetDatabaseSearching.cs:21) UnityEditor.AssetDatabase.FindAssets (System.String filter) (at C:/buildslave/unity/build/Editor/Mono/AssetDatabaseSearching.cs:11) Dissonance.DissonanceResourceLocator.get_BaseLocation () (at Assets/ImmersiveDeck/Dependencies/Dissonance/Ressources/DissonanceResourceLocator.cs:23) Dissonance.DissonanceResourceLocator.GetPathForAsset (System.String name) (at Assets/ImmersiveDeck/Dependencies/Dissonance/Ressources/DissonanceResourceLocator.cs:37) Dissonance.Config.VoiceSettings..cctor () (at Assets/ImmersiveDeck/Dependencies/Dissonance/Plugins/Dissonance/Core/Config/VoiceSettings.cs:25) Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Dissonance.Config.VoiceSettings

martindevans commented 7 years ago

I edited my last post to cross out the instructions (I noticed the same errors immediately after I posted). Sorry about that, I really should have posted another comment instead.

martindevans commented 7 years ago

Ok sorry about that last time. I've now learnt more about unity asset serialization than I ever wanted to and have come full circle back to the first thing I thought of, I've added this class:

namespace Dissonance
{
    internal static class DissonanceRootPath
    {
        private const string BasePath = "Assets/Plugins/Dissonance";

        internal const string BaseResourcePath = BasePath + "/Resources";
    }
}

And made the obvious changes to the four locations (e.g. public static readonly string SettingsFilePath = Path.Combine(DissonanceRootPath.BaseResourcePath, SettingsFileResourceName + ".asset");).

TobiasWehrum commented 7 years ago

Aw. So no automatic detection for now?

martindevans commented 7 years ago

Unfortunately not :(

I did spend a load of time trying to get that to work but I need to do some more research on how the Unity AssetDatabase works (when I'm allowed to touch it, how to find things at runtime vs editor time etc).

TobiasWehrum commented 7 years ago

Okay. Like I suggested in the second post - a global path is definitely good enough for me at the moment. Thanks!

martindevans commented 7 years ago

Dissonance 3.0.1 has just released on the Unity asset store, this includes the changes made to resolve this issue so I'll close it now. If the problem persists please feel free to continue posting in this thread. If you're happy with how this issue was handled please consider rating and reviewing us on the asset store!