Example #1
0
        public SettingPage()
        {
            OptionNames              = new List <string>();
            Options                  = new MemoryOptions(Options.Current);
            Options.ModifiedChanged += Options_ModifiedChanged;

            LanguageManage.CurrentChanged += LanguageManage_CurrentChanged;
            UITheme.Default.Listeners.Add(this);
        }
        public UnsafeArrayList(int capacity, Allocator allocator, MemoryOptions options = MemoryOptions.ClearMemory)
        {
            _memoryManager = default;
            _arrayListData = _memoryManager.Init <UnsafeArrayListData>(1, allocator, options);

            UnsafeArrayListData.Buffer = (UnsafeArrayListData *)_memoryManager
                                         .Allocate <MemoryManagerUnsafe <UnsafeArrayList <T> >, UnsafeArrayList <T>, T>(capacity, options);
            UnsafeArrayListData.Length   = 0;
            UnsafeArrayListData.Capacity = capacity;
        }
        public unsafe void *Init <T>(int size, Allocator allocator, MemoryOptions options)
            where T : struct
        {
            UnsafeCollectionsHelpers.IsAlreadyCreatedAndThrow <Container>(_allocator);
            UnsafeCollectionsHelpers.IsCorrectAllocatorAndThrow <Container>(allocator);

            _allocator = allocator;

            return(this.Allocate <MemoryManagerUnsafe <Container>, Container, T>(size, options));
        }
Example #4
0
        public NativeUnit(Allocator allocator, MemoryOptions options = MemoryOptions.ClearMemory)
        {
            _memoryManager = default;
            _buffer        = _memoryManager.Init <T>(1, allocator
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                                                     , out m_Safety
#endif
                                                     , options
                                                     );
        }
        public unsafe void *Init <T>(int size, Allocator allocator
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                                     , out AtomicSafetyHandle atomicSafetyHandle
#endif
                                     , MemoryOptions options
                                     )
            where T : struct
        {
            UnsafeCollectionsHelpers.IsAlreadyCreatedAndThrow <Container>(_allocator);
            UnsafeCollectionsHelpers.IsCorrectAllocatorAndThrow <Container>(allocator);

            _allocator = allocator;

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            DisposeSentinel.Create(out atomicSafetyHandle, out _disposeSentinel, 0, allocator);
            _atomicSafetyHandle = atomicSafetyHandle;
#endif

            return(this.Allocate <MemoryManager <Container>, Container, T>(size, options));
        }
 public UnsafeArrayList(Allocator allocator, MemoryOptions options) : this(0, allocator, options)
 {
 }
Example #7
0
        public static unsafe void *Allocate <M, C, T>(this M memoryManager, int size, MemoryOptions options)
            where M : struct, IDefaultMemoryManager
            where C : struct
            where T : struct
        {
            UnsafeCollectionsHelpers.IsBlittableAndThrow <C, T>();

            var totalSize = size * UnsafeUtility.SizeOf <T>();

            UnsafeCollectionsHelpers.IsCorrectSizeAndThrow <C>(totalSize);

            var buffer = UnsafeUtility.Malloc(
                totalSize,
                UnsafeUtility.AlignOf <T>(),
                memoryManager.Allocator
                );

            if ((options & MemoryOptions.ClearMemory) == MemoryOptions.ClearMemory)
            {
                UnsafeUtility.MemClear(buffer, totalSize);
            }

            return(buffer);
        }
Example #8
0
 static Options()
 {
     DefaultValue = new MemoryOptions();
     Current      = new FileSystemOptions(DefaultValue);
 }