Sorry am I missing how GameName.Length != 0 if I set the GameName = “” (an empty string?).
I’m not sure what your question is? This statement evaluates to true: FixedString64("").Length == 0.
default and “” are the same. So if you want to check for != null you can just check for .Length != 0
Here is a test that passes showing it:
[Test]
[Category("ecs lowlevel")]
public void FixedString64Empty()
{
var fStrEmpty = new FixedString64("");
var fStrDefault = default(FixedString64);
Assert.AreEqual(0, fStrEmpty.Length);
Assert.AreEqual(0, fStrDefault.Length);
Assert.IsTrue(fStrEmpty == fStrDefault);
Assert.IsTrue(fStrEmpty == default(FixedString64));
}
Sorry for being unclear @jasons-novaleaf !
- What I meant to say is that a user is given the option to set the game name
- They have the option to set the game name to “”
- I wanted to CHECK, if the GameName had been set (as part of a start up flow)
- It seems like I wouldn’t be able to tell the difference between them NOT setting it (“”) or them setting it to “”
Check and see if you can use nullable types. if not, add an extra .isSet boolean field to your ClientDataComponent
1 Like
NICE!!!
.isSet! so obvious but terrific, thank yoU!