FixedString Noob Question with Job System (No Entities)

Hi there,

Sorry for asking basic stuff but i did tried both forum search and google search but didnt find anyting that answers these questions, so i really appreciate someone who has experienced with this can answer these.

  • If im not mistaken, we can now have NativeList,

So my question is;
Can this approach works with JobSystem and BurstCompiler where ill have a NativeList of “english words” to perform string comparisons operations ?

Thanks

Yes. But you can’t use string literals like “SomeName”. Liternal=>FixString must be done outside of job.
You can append format FixedStrings in job.

1 Like

I wont be using string literal inside the job, but FixedString itself, isnt it possible? like my example below

struct ScrabbleJob : IJob
    {
       
        [ReadOnly]
        public NativeList<FixedString> EnglishWordsEnteredByUser;
   
        [ReadOnly]
        public NativeHashSet<FixedString> EnglishWordsDictionary;


        public NativeArray<bool> Result;


        public void Execute()
        {

            bool AllValid = true;
           
            for (int j = 0; j < EnglishWordsEnteredByUser.Count; j++)
            {
                var currentWord = EnglishWordsDictionary[j];

                if (EnglishWordsDictionary.Contains(currentWord) == false)
                {
                    AllValid = false;
                }
            }

            Result[0] = AllValid;
        }
    }

That should work

1 Like

Thanks, and what should i use for saving english words of varying length, FixedString or NativeString?

Keep in mind that (according to the Unity Collections package changelog) NativeString is now deprecated in favor of FixedString. Currently you should use the FixedString variant that supplies you with enough character capacity for your needs.

Here’s a comment with some guidance from NativeString.gen.cs but probably applies to FixedString* too:

1 Like

Thanks, appreciate that :slight_smile:

According to this, the longest “real” word (not a chemical name and not invented for the purpose of being long) is 30 letters: Longest word in English - Wikipedia Which just squeaks into a FixedString32.

1 Like

There should be a Generic FixedString which takes space based on the word length as putting FixedString32 means i;ll be forced to save all the words 32 as its a NativeArray. Or is there a better way?