Beispiel #1
0
        public static unsafe TransformAccessArray GetTransformAccessArray(this EntityQuery group)
        {
            var state        = (TransformAccessArrayState?)group.m_CachedState ?? new TransformAccessArrayState();
            var orderVersion = group.EntityDataManager->GetComponentTypeOrderVersion(TypeManager.GetTypeIndex <Transform>());

            if (state.Data.isCreated && orderVersion == state.OrderVersion)
            {
                return(state.Data);
            }

            state.OrderVersion = orderVersion;

            UnityEngine.Profiling.Profiler.BeginSample("DirtyTransformAccessArrayUpdate");
            var trans = group.ToComponentArray <Transform>();

            if (!state.Data.isCreated)
            {
                state.Data = new TransformAccessArray(trans);
            }
            else
            {
                state.Data.SetTransforms(trans);
            }
            UnityEngine.Profiling.Profiler.EndSample();

            group.m_CachedState = state;

            return(state.Data);
        }