public override void Accept(ref EntityContainer container, IPropertyVisitor visitor) { var count = container.m_Manager.GetComponentCount(container.m_Entity); var listContext = new ListContext <IList <StructProxy> > { Property = this, Value = null, Index = -1, Count = count }; // @TODO improve, split the deps HashSet <Type> primitiveTypes = new HashSet <Type>(); // try to gather the primitive types for that visitor var entityVisitor = visitor as IPrimitivePropertyVisitor; if (entityVisitor != null) { primitiveTypes = entityVisitor.SupportedPrimitiveTypes(); } else { // @TODO remove that dependency // Fallback on the optimized visitor for now primitiveTypes = OptimizedVisitor.SupportedTypes(); } if (visitor.BeginList(ref container, listContext)) { for (var i = 0; i < count; i++) { var item = Get(ref container, i, primitiveTypes); var context = new SubtreeContext <StructProxy> { Property = this, Value = item, Index = i }; if (visitor.BeginContainer(ref container, context)) { item.PropertyBag.VisitStruct(ref item, visitor); } visitor.EndContainer(ref container, context); } } visitor.EndList(ref container, listContext); }
public bool BeginContainer <TContainer, TValue>(ref TContainer container, SubtreeContext <TValue> context) where TContainer : IPropertyContainer { EditorGUI.indentLevel++; if (typeof(TValue) == typeof(StructProxy)) { ComponentState state; if (!_states.ContainsKey(context.Index)) { _states[context.Index] = new ComponentState(); } state = _states[context.Index]; state.Showing = EditorGUILayout.Foldout(state.Showing, context.Property.Name); return(state.Showing); } return(true); }
public void EndContainer <TContainer, TValue>(ref TContainer container, SubtreeContext <TValue> context) where TContainer : IPropertyContainer { EditorGUI.indentLevel--; }