I have some custom c# logic to interact with my UI. Whenever I change the uxml or uss, the c# script no longer is able to interact with the UI.
Maybe something like the [DidReloadScripts] attribute…
Any ideas?
I have some custom c# logic to interact with my UI. Whenever I change the uxml or uss, the c# script no longer is able to interact with the UI.
Maybe something like the [DidReloadScripts] attribute…
Any ideas?
[ScriptedImporter(1, "uxml")]
public class UxmlImporter : ScriptedImporter
{
public override void OnImportAsset(AssetImportContext ctx)
{
Debug.Log("Uxml saved");
}
}
https://docs.unity3d.com/ScriptReference/Experimental.AssetImporters.ScriptedImporter.html
Nice! I’ll play around with this. Thanks Kirsche!
Hmmm. Doesn’t seem like it works - apparently there can only be one active scripted importer at a time? Thanks though, for the tip
Hello, it wasn’t clear from your question but I guess you’re talking about Runtime, right?
If so, in the same Game Object where you have your UIDocument, you should add your own MonoBehaviour and implement the changes you want to always run with the reload of the UXML/USS on your OnEnable method.
Hope this helps!
Same thing, I am trying to run some code when the InputAction asset is change - kinda like the Generate C# Class that it comes with, issue being it already has a custom ScriptedImporter so I cant just add my own.
I have tried
UnityEditor.AssetModificationProcessor and
AssetPostprocessor
But both of those dont seem to trigger on changes to the underlying asset.
Any ideas how to do it ?
Same question as Morphex above, would really love to be able to trigger some logic when .inputactions files change but can’t use a second importer, anyone have any ideas?
I used an AssetPostProcessor to generate some source files for my uxml (Seems to work fine for me in 2020.2). So the same should work with .inputactions too.