private LabelEntryMatchCache(LabelEntryMatchCache labelEntryMatchCache, Allocator allocator)
 {
     m_IdLabelConfig = labelEntryMatchCache.m_IdLabelConfig;
     m_InstanceIdToLabelEntryIndexLookup = new NativeList <ushort>(labelEntryMatchCache.m_InstanceIdToLabelEntryIndexLookup.Length, allocator);
     m_InstanceIdToLabelEntryIndexLookup.AddRange(labelEntryMatchCache.m_InstanceIdToLabelEntryIndexLookup.AsArray());
     m_ReceiveUpdates = false;
 }
Пример #2
0
 private void EnsureInitLabelEntryMatchCache()
 {
     if (m_LabelEntryMatchCache == null)
     {
         m_LabelEntryMatchCache = new LabelEntryMatchCache(this, Allocator.Persistent);
     }
 }
        /// <summary>
        /// Attempts to find the label id for the given instance id.
        /// </summary>
        /// <param name="instanceId">The instanceId of the object for which the labelId should be found</param>
        /// <param name="labelEntry">The LabelEntry associated with the object. default if not found</param>
        /// <param name="index">The index of the found LabelEntry in <see cref="LabelConfig{T}.labelEntries"/>. -1 if not found</param>
        /// <returns>True if a labelId is found for the given instanceId.</returns>
        public bool TryGetLabelEntryFromInstanceId(uint instanceId, out IdLabelEntry labelEntry, out int index)
        {
            if (m_LabelEntryMatchCache == null)
            {
                m_LabelEntryMatchCache = new LabelEntryMatchCache(this);
            }

            return(m_LabelEntryMatchCache.TryGetLabelEntryFromInstanceId(instanceId, out labelEntry, out index));
        }
 void OnDisable()
 {
     m_LabelEntryMatchCache?.Dispose();
     m_LabelEntryMatchCache = null;
 }
        internal LabelEntryMatchCache CloneCurrentState(Allocator allocator)
        {
            var clone = new LabelEntryMatchCache(this, Allocator.Persistent);

            return(clone);
        }