当前位置: 首页>>代码示例>>C#>>正文


C# IComponent.CopyPublicMemberValues方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:JamesMcMahon,项目名称:entitas-2d-roguelike,代码行数:51,代码来源:EntityDrawer.cs

示例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);
     }
 }
开发者ID:JamesMcMahon,项目名称:entitas-2d-roguelike,代码行数:10,代码来源:EntityDrawer.cs


注:本文中的IComponent.CopyPublicMemberValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。