Ejemplo n.º 1
0
        public void AddNewItem()
        {
            var buffer = GetData(MainTarget);

            buffer.Add(new TBufferElementData());
            EntityInspector.ForceRebuildAll();
        }
Ejemplo n.º 2
0
        public void RemoveDataAtIndex(int index)
        {
            var buffer = GetData(MainTarget);

            buffer.RemoveAt(index);
            ResetIndices(index);
            EntityInspector.ForceRebuildAll();
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }