Component prefabs
So I was able to get prefabs working with the component design. It's really easy too! A prefab is just an xml file that describes the different components and their attributes that make a game object.
For example, in the editor I added an empty game object to my scene, then attached a spotlight component to it. This provides spotlight functionality. It creates an LE spotlight and exposes some attributes to control the spotlight. I then right click the game object and choose Save As Prefab. I provide it a name (SpotLight) and it saves an xml file named SpotLight which has the components required for that game object and saves the attributes that were set. Now when I go to add a game object I have another menu option named Prefabs, which lists all available prefabs. SpotLight shows up! I select it and it adds a game object to the scene and automatically attaches the spotlight component to it and sets the default settings. It's that easy. Distribute your prefab xml file and any component dll's that depend on it and people can add your game objects to their scene with a click of a button.
The editor will also validate if a dependent component is missing or not and inform you of the missing component.
This is getting exciting
More to come!
11 Comments
Recommended Comments