ProwlEngine / Prowl

An Open Source C# 3D Game Engine under MIT license, inspired by Unity and featuring a complete editor and built on Silk.NET
MIT License
360 stars 30 forks source link

[Engine] Prefabs #79

Closed michaelsakharov closed 9 months ago

michaelsakharov commented 9 months ago

Prefabs are just GameObjects as Resources

The easiest API would be something like:

Prefab prefab = AssetDatabase.LoadAsset<Prefab>(guid);
GameObject instance = prefab.Instantiate();

Which i think works well, in unity now you have todo

GameObject prefab = Resources.Load("prefabName") as GameObject;
GameObject instance = Instantiate(prefab);

I think I prefer having a separation between GameObject and Prefab, to make it clear when the game object you have is an Asset and not a gameobject in the world.

Using it from a variable would be:

public AssetRef<Prefab> prefab;

public void Start();
{
    GameObject instance = prefab.Instantiate();
}

And in Unity:

public GameObject prefab;

public void Start();
{
    GameObject instance = Instantiate(prefab);
}
michaelsakharov commented 9 months ago

Simple prefabs are implemented, no Nesting or Variants yet

michaelsakharov commented 9 months ago

Im gonna make Nesting & Variants as seperate issues, base Prefabs are done