Generating non-components

Hi guys,

is there a technical reason why plain objects do not get translated by the component generator?

When designing components I like to split config data into separate classes if the interface gets too messy or if I need several items of the same thing.

It gets pretty tedious to maintain them on both ts and c# side, especially when there’s pretty much everything already there in the component generator.

I can even get pretty close by decorating my ts class with something like

// @generate-component
// @type object
export class MyData {
...

Now all that’s missing from the generated class is the [Serializable] attribute :slight_smile:

I’m sorry, I couldn’t find a response but notified the team :exploding_head:

Hi,

The next update of the component compiler adds support to automatically decorate classes with [System.Serializable] when you mark them with // @type object

E.g. in your typescript:

// @type object
export class Container {
    @serializable(Object3D)
    objectA?: Object3D[];
}

will generate C#

namespace Needle.Typescript.GeneratedComponents
{
	[System.Serializable]
	public partial class Container : object
	{
		public UnityEngine.GameObject[] @objectA;
	}
}
1 Like

This topic was automatically closed 13 days after the last reply. New replies are no longer allowed.