public override void OnEnable() { base.OnEnable(); entity = (PEntity)target; InitializeCategories(); }
void CheckRequiredComponents(PEntity entity) { errors.Clear(); if (!fieldInfo.IsDefined(typeof(EntityRequiresAttribute), true)) return; var attribute = (EntityRequiresAttribute)fieldInfo.GetCustomAttributes(typeof(EntityRequiresAttribute), true)[0]; if (entity == null && !attribute.CanBeNull) errors.Add(string.Format("Field cannot be null.").ToGUIContent()); if (entity == null) return; for (int j = 0; j < attribute.Types.Length; j++) { var type = attribute.Types[j]; if (type != null && typeof(IComponentOld).IsAssignableFrom(type) && !entity.HasComponent(type)) errors.Add(string.Format("Missing required component: {0}", type.Name).ToGUIContent()); } }