- Home /
Can I create a game object from a dll?
I want to programatically create a game object and add it to my scene. Can I do this from a dll?
Answer by hexagonius · Dec 20, 2018 at 06:44 PM
Yes. managed dlls can call everything you call in regular scripts as long as you link to UnityEngine for example
Do you know if this created game object will work on iOS? I have this code that I packed into a dll:
using UnityEngine;
public class DLLTest : $$anonymous$$onoBehaviour {
[RuntimeInitializeOnLoad$$anonymous$$ethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
public static void Initialize()
{
var go = new GameObject(typeof(DLLTest).FullName);
go.AddComponent<DLLTest>();
}
// Use this for initialization
void Start () {
Debug.Log("Starting test");
}
// Update is called once per frame
void Update () {
}
}
When I build the project to iOS, my game object does not seem to be created at all.
check the attribute documentation sample and compare the class signature
Your answer
Follow this Question
Related Questions
Calling an Audio Source on one game object from a script on another game object..? 1 Answer
Best workflow for DontDestroyOnLoad method regarding Unity Editor? 1 Answer
How Can I Copy My Gameobject To Other Scene How Can I Copy Gameobject to different scene 1 Answer
List objects in a scene file 0 Answers
Levels: scenes or GameObjects? 3 Answers