Exemplo n.º 1
0
 public NativeString4096(ref NativeString64 source)
 {
     Length = 0;
     unsafe
     {
         CopyFrom(source.GetUnsafePtr(), source.Length);
     }
 }
        /// <summary>
        /// This method returns all entity names for the given array of entityGuid components.
        /// </summary>
        /// <remarks>
        /// This method relies on the source buffers the entityGuids was built from. While this could technically be done
        /// while building the entityGuid set, it's a bit more isolated this way so we can remove it easily in the future.
        /// </remarks>
        private NativeArray <NativeString64> GetEntityNames(
            NativeList <EntityGuid> entityGuids,
            NativeList <EntityInChunkWithComponent <EntityGuid> > createdEntities,
            NativeList <ModifiedEntity> modifiedEntities,
            NativeList <EntityInChunkWithComponent <EntityGuid> > destroyedEntities,
            EntityManager afterEntityManager,
            EntityManager beforeEntityManager,
            Allocator allocator)
        {
            var names = new NativeArray <NativeString64>(entityGuids.Length, allocator);
            var index = 0;

            // Created entities will ALWAYS show up in the entityGuid set so we can safely grab the names.
            // They will exist in the after world.
            for (var i = 0; i < createdEntities.Length; i++)
            {
                var name = new NativeString64();
#if UNITY_EDITOR
                name.CopyFrom(afterEntityManager.GetName(GetEntityFromEntityInChunk(createdEntities[i].EntityInChunk)));
#endif
                names[index++] = name;
            }

            // Scan through the potentially modified entities and extract names for ones that were actually changed.
            // Use the after world name.
            var entityGuidIndex = createdEntities.Length;
            for (var i = 0; i < modifiedEntities.Length && entityGuidIndex < entityGuids.Length; i++)
            {
                if (!modifiedEntities[i].EntityGuid.Equals(entityGuids[entityGuidIndex]))
                {
                    continue;
                }

                var name = new NativeString64();
#if UNITY_EDITOR
                name.CopyFrom(afterEntityManager.GetName(GetEntityFromEntityInChunk(modifiedEntities[i].After)));
#endif
                names[index++] = name;
                entityGuidIndex++;
            }

            // Destroyed entities will always show up int he entityGuid set so we can grab the rest of those names.
            // The will not exist in the after world so use the before world.
            for (var i = 0; i < destroyedEntities.Length; i++)
            {
                var name = new NativeString64();
#if UNITY_EDITOR
                name.CopyFrom(beforeEntityManager.GetName(GetEntityFromEntityInChunk(destroyedEntities[i].EntityInChunk)));
#endif
                names[index++] = name;
            }

            return(names);
        }
Exemplo n.º 3
0
        public NativeString512(ref NativeString64 source)
        {
            Length = source.Length;
            unsafe
            {
                fixed(uint *b = buffer)
                {
                    var d = (char *)b;

                    source.CopyTo(d, MaxLength);
                }
            }
        }