예제 #1
0
        public void AddNewItem()
        {
            var buffer = GetData(MainTarget);

            buffer.Add(new TBufferElementData());
            EntityInspector.ForceRebuildAll();
        }
예제 #2
0
        public void RemoveDataAtIndex(int index)
        {
            var buffer = GetData(MainTarget);

            buffer.RemoveAt(index);
            ResetIndices(index);
            EntityInspector.ForceRebuildAll();
        }
예제 #3
0
 private static bool Process(string[] paths)
 {
     if (!paths.Any(path => path.EndsWith(k_UxmlExtension, StringComparison.InvariantCultureIgnoreCase)))
     {
         return(false);
     }
     if (Application.AuthoringProject != null)
     {
         EntityInspector.ForceRebuildAll();
     }
     return(true);
 }
예제 #4
0
        private bool AddType(SearcherItem item)
        {
            if (!(item is TypeSearcherItem typedItem))
            {
                return(false);
            }

            item.Database.ItemList.Remove(item);

            foreach (var entity in Targets)
            {
                var type  = typedItem.Type;
                var index = TypeManager.GetTypeIndex(type);
                if (!EntityManager.HasComponent(entity, type))
                {
                    EntityManager.AddComponent(entity, type);
                    if (TypeManager.IsZeroSized(index))
                    {
                        continue;
                    }

                    if (typeof(IComponentData).IsAssignableFrom(type))
                    {
                        unsafe
                        {
                            var data         = EntityManager.GetComponentDataRawRW(entity, index);
                            var defaultValue = DomainCache.GetDefaultValue(type);
                            // TODO: Find a better way
                            typeof(UIElementsBackend)
                            .GetMethod(nameof(Copy), BindingFlags.NonPublic | BindingFlags.Instance)?
                            .MakeGenericMethod(type)
                            .Invoke(this, new [] { entity, index, defaultValue });
                        }
                    }
                }
            }
            EntityInspector.ForceRebuildAll();
            return(true);
        }