extern internal static bool RegisterEntityClass(EntityRegistrationParams registerParams);
IScriptRegistrationParams TryGetEntityParams(Type type) { var entityRegistrationParams = new EntityRegistrationParams(); BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; var members = type.GetMembers(flags); var entityProperties = new Dictionary <string, List <EditorProperty> >(); members.ForEach(member => TryGetEntityProperty(member, ref entityProperties)); int numProperties = entityProperties.Count; if (numProperties > 0) { var properties = new List <object>(); foreach (var folder in entityProperties) { if (folder.Key != "Default") { properties.Add(new EditorProperty(folder.Key, null, null, EditorPropertyType.FolderBegin)); properties.AddRange(folder.Value.Cast <object>()); properties.Add(new EditorProperty(folder.Key, null, null, EditorPropertyType.FolderEnd)); } else { properties.AddRange(folder.Value.Cast <object>()); } } entityRegistrationParams.properties = properties.ToArray(); } var curType = type; bool changedFlags = false; var entType = typeof(Entity); // This should not be specific to entities, all scripts should be able to utilize this parent class attribute functionality. while (curType != entType) { EntityAttribute entAttribute; if (curType.TryGetAttribute(out entAttribute)) { // don't override if the type before this (or earlier) changed it. if (entityRegistrationParams.name == null) { entityRegistrationParams.name = entAttribute.Name; } if (entityRegistrationParams.category == null) { entityRegistrationParams.category = entAttribute.Category; } if (entityRegistrationParams.editorHelper == null) { entityRegistrationParams.editorHelper = entAttribute.EditorHelper; } if (entityRegistrationParams.editorIcon == null) { entityRegistrationParams.editorIcon = entAttribute.Icon; } if (!changedFlags) { entityRegistrationParams.flags = entAttribute.Flags; changedFlags = true; } } curType = curType.BaseType; } return(entityRegistrationParams); }
bool TryGetEntityParams(ref IScriptRegistrationParams registrationParams, Type type) { var entityRegistrationParams = new EntityRegistrationParams(); BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; var members = type.GetMembers(flags); var entityProperties = new Dictionary <string, List <EditorProperty> >(); members.ForEach(member => TryGetEntityProperty(member, ref entityProperties)); int numProperties = entityProperties.Count; if (numProperties > 0) { var folders = new EditorPropertyFolder[numProperties]; for (int i = 0; i < numProperties; i++) { var folderPair = entityProperties.ElementAt(i); var folder = new EditorPropertyFolder(); folder.name = folderPair.Key; folder.properties = folderPair.Value.Cast <object>().ToArray(); folders[i] = folder; } entityRegistrationParams.propertyFolders = folders.Cast <object>().ToArray(); } var curType = type; bool changedFlags = false; var entType = typeof(Entity); // This should not be specific to entities, all scripts should be able to utilize this parent class attribute functionality. while (curType != entType) { EntityAttribute entAttribute; if (curType.TryGetAttribute(out entAttribute)) { // don't override if the type before this (or earlier) changed it. if (entityRegistrationParams.name == null) { entityRegistrationParams.name = entAttribute.Name; } if (entityRegistrationParams.category == null) { entityRegistrationParams.category = entAttribute.Category; } if (entityRegistrationParams.editorHelper == null) { entityRegistrationParams.editorHelper = entAttribute.EditorHelper; } if (entityRegistrationParams.editorIcon == null) { entityRegistrationParams.editorIcon = entAttribute.Icon; } if (!changedFlags) { entityRegistrationParams.flags = entAttribute.Flags; changedFlags = true; } } curType = curType.BaseType; } registrationParams = entityRegistrationParams; return(true); }
extern public static bool RegisterEntityClass(EntityRegistrationParams registerParams);