Jump to content

Accessing another plugin


Recommended Posts

I want to add the functionality of another plugin, but only if the plugin is already being used. I've seen this done, when two plugins are Parts, but, not if one of the plugins is a non-part.

The other plugin I wish to use inherits from MonoBehaviour, not PartModule.

I've tried:

* GetComponent

* FindObjectOfType (this actually worked, if the other plugin was in the same folder as my own)

What I want to do is check if this other class has been loaded, and if so, add some extra functionality to my own Part, and then call a function in the other class eventually.

How is this possible? Is this possible?

(God I hope this question makes sense!)

Link to comment
Share on other sites

FindObjectOfType would have been my suggestion, what exactly was wrong with it? If it wasn't working when the plugin was in another folder then were you calling it in OnAwake()? If so then the game may not have loaded the other plugin yet and it may work if you call it later.

You should be able check whether a plugin has been loaded using something like Type.GetType("ClassName"). If it's non-null the class has been loaded. That doesn't guarantee the plugin is currently running though, and won't provide it's current instantiation for you to call non-static methods on though.

Link to comment
Share on other sites

He is talking about my plugin "Mission Controller" and I tried what you said, but Type.GetType("MissionController.MissionController") returns null, when I call it outside the mission controller plugin.

And if I add a C# reference to my MissionController.dll and call Type.GetType(MissionController.MissionController) it does work, *BUT* it will need the mission controller library to load the plugin. It's a hard dependency and I would like to avoid that.

/EDIT:

Never mind, figured it out:

You have to specify the dll name if the class is in another assembly:

Type t = Type.GetType ("MissionController.Manager,MissionController"); works.

So I guess I will code an interface.

Edited by nobody44
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...