aliessmael/Unity-Logs-Viewer

Reporter.cs images not correctly loaded for non-root installation path

hsandt opened this issue · 2 comments

If the Reporter folder is not located directly in Assets, image paths such as "Assets/Reporter/Images/clear.png" refered in ReporterEditor.cs are not correct, hence the Reporter object created via the Reporter > Create menu is not initialized correctly: all image bindings are empty.

I am trying to get the path of the ReporterEditor.cs script to deduce the path but it's hard to do that in a *static * method. Otherwise I'd do something like

// MonoScript scriptAsset = MonoScript.FromScriptableObject(this);
        // string reporterPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(scriptAsset));

assuming MyAssetModificationProcessor is turned into an EditorWindow (which is a ScriptableObject) instead of an AssetModificationProcessor.

For now I am changing the path manually with:

string reporterPath = "Assets/Unity-Logs-Viewer/Reporter";
reporter.images.clearImage          = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/clear.png"), typeof(Texture2D));
...

Since Reporter is not the root of the repository anymore, we have to expect users to clone the repository inside some Assets sub-folder, probably named "Reporter" (but a parent) or "Unity-Logs-Viewer" since it is the name of the repository.

By the way, there are no images for showGraphImage and cameraImage for the said script, although I guess the images are not used much. Maybe we should open a new issue for that.

Thanks for suggestion, I have fixed it and removed unused image also.

Great!

I hadn't considered getting the path of the Reporter script since the static method does not know an instance of its own class... I'll remember that trick.