To my understanding, everything in Plugins is compiled before the rest of the scripts in Assets.
I’m running into a bit of a stuck situation where I need one C# script badly to communicate with another C# script, except the other script is located under Plugins.
I went ahead and tried anyways, but I get “The type or namespace name `MyParticularScript’ could not be found. Are you missing a using directive or an assembly reference?”
I’m aware of compilation order. If there’s a trick to somehow do this, it would save me an incredible headache!
Asset accessing Plugin should be fine.
Plugin accessing Asset is obviously an no-go.
Are you sure it’s a script in asset accessing plugin? It works fine here. Maybe your script in plugin is in a namespace?
The script in Plugins needs to access a script in Assets.
It’s a no-go then? Utter hopelessness?
Why is that script in Plugins? Anything in Plugin should be self-contain.
Long story short, it had to be moved to Plugins in order for Javascript to be able to access it
Accessing Assets from Plugins in the normal way is pretty much impossible as LightStriker says. But there are some tricks using reflection to get it to work, but the code is ugly. For example, if you can get the component on an object using GetComponent (without the <> since you can’t use the type), you can then call a method named “SomeMethod()” that takes returns an int like this:
return (int) component.GetType().GetMethod("SomeMethod").Invoke(component, p)
p in there would be an object[ ] array of parameters.
Yeah, but you won’t get any definition or type, and you would have to “hard-code” every method call by string. It would still have to compile with any real dependency on the Assets.
Frankly, I would try to fix the design flaws you have before doing some hacks like that.
Maybe if you explain a bit more the issue and why you ended up in a situation like that, we could give you better solution.