本文整理汇总了C#中IComponent.CopyPublicMemberValues方法的典型用法代码示例。如果您正苦于以下问题:C# IComponent.CopyPublicMemberValues方法的具体用法?C# IComponent.CopyPublicMemberValues怎么用?C# IComponent.CopyPublicMemberValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IComponent
的用法示例。
在下文中一共展示了IComponent.CopyPublicMemberValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawComponent
public static void DrawComponent(bool[] unfoldedComponents, Entity entity, int index, IComponent component)
{
var componentType = component.GetType();
var componentName = componentType.Name.RemoveComponentSuffix();
if (componentName.ToLower().Contains(_componentNameSearchTerm.ToLower())) {
var boxStyle = getColoredBoxStyle(entity.totalComponents, index);
EntitasEditorLayout.BeginVerticalBox(boxStyle);
{
var memberInfos = componentType.GetPublicMemberInfos();
EntitasEditorLayout.BeginHorizontal();
{
if (memberInfos.Count == 0) {
EditorGUILayout.LabelField(componentName, EditorStyles.boldLabel);
} else {
unfoldedComponents[index] = EditorGUILayout.Foldout(unfoldedComponents[index], componentName, _foldoutStyle);
}
if (GUILayout.Button("-", GUILayout.Width(19), GUILayout.Height(14))) {
entity.RemoveComponent(index);
}
}
EntitasEditorLayout.EndHorizontal();
if (unfoldedComponents[index]) {
var componentDrawer = getComponentDrawer(componentType);
if (componentDrawer != null) {
var newComponent = entity.CreateComponent(index, componentType);
component.CopyPublicMemberValues(newComponent);
EditorGUI.BeginChangeCheck();
{
componentDrawer.DrawComponent(newComponent);
}
var changed = EditorGUI.EndChangeCheck();
if (changed) {
entity.ReplaceComponent(index, newComponent);
} else {
entity.GetComponentPool(index).Push(newComponent);
}
} else {
foreach (var info in memberInfos) {
DrawAndSetElement(info.type, info.name, info.GetValue(component),
entity, index, component, info.SetValue);
}
}
}
}
EntitasEditorLayout.EndVertical();
}
}
示例2: DrawAndSetElement
public static void DrawAndSetElement(Type memberType, string memberName, object value, Entity entity, int index, IComponent component, Action<IComponent, object> setValue)
{
var newValue = DrawAndGetNewValue(memberType, memberName, value, entity, index, component);
if (DidValueChange(value, newValue)) {
var newComponent = entity.CreateComponent(index, component.GetType());
component.CopyPublicMemberValues(newComponent);
setValue(newComponent, newValue);
entity.ReplaceComponent(index, newComponent);
}
}