Answer the question
In order to leave comments, you need to log in
Where should string parameters be stored in unity entities?
public struct PlayerNameTag : IComponentData {
public string playerName;
}
ArgumentException: Components.UITags.Creation.PlayerPortraitTag contains a field of System.String, which is neither primitive nor blittable.
Answer the question
In order to leave comments, you need to log in
It is worth considering that it NativeString
has a length limit (there are only three options for this class: NativeString64
, NativeString512
and NativeString4096
). Due to the poor API, working with this class as a string is not so convenient.
There are at least a couple of other solutions to the problem. The simplest is to store the strings in some kind of list, and specify the index of the string from this list in the component.
You can also create a component that implements not IComponentData
, but ISharedComponentData
. Such components allow you to store data of a reference type.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question