wpf游戏引擎的script实现

1.script.cs

using System.IO;

using System.Runtime.Serialization;

using System.Text;

namespace PrimalEditor.Components

{

DataContract

class Script : Component

{

private string _name;

DataMember

public string Name

{

get => _name;

set

{

if (_name != value)

{

_name = value;

OnPropertyChanged(Name);

}

}

}

public override IMSComponent GetMultiselectionComponent(MSEntity msEntity) => new MSScript(msEntity);

public override void WriteToBinary(BinaryWriter bw)

{

var nameBytes = Encoding.UTF8.GetBytes(Name);

bw.Write(nameBytes.Length);

bw.Write(nameBytes);

}

public Script(GameEntity owner) : base(owner)

{

}

}

sealed class MSScript : MSComponent<Script>

{

private string _name;

DataMember

public string Name

{

get => _name;

set

{

if (_name != value)

{

_name = value;

OnPropertyChanged(Name);

}

}

}

protected override bool UpdateComponents(string propertyName)

{

if (propertyName == nameof(Name))

{

SelectedComponents.ForEach(c => c.Name = _name);

return true;

}

return false;

}

protected override bool UpdateMSComponent()

{

Name = MSEntity.GetMixedValue(SelectedComponents, new Func<Script, string>(x => x.Name));

return true;

}

public MSScript(MSEntity msEntity) : base(msEntity)

{

Refresh();

}

}

}

相关推荐
_ZHOURUI_H_4 小时前
Unity MyFramework 用法说明(二十三):使用 PrefabPoolManager 复用预设实例
unity·游戏引擎·游戏开发·游戏ui·手游开发
新手unity自用笔记10 小时前
unity网络基础_1
网络·unity·游戏引擎
脚踏实地皮皮晨18 小时前
003002004_WPF Panel 基类 官方类定义
开发语言·windows·算法·c#·wpf·visual studio
湿滑路面1 天前
Rouyan:使用WPF/C#构建的基于LLM的快捷翻译小工具
开发语言·c#·wpf
软萌萌的11 天前
C#中的多级缓存架构设计与实现深度解析
缓存·c#·wpf
dalong102 天前
WPF:3D正八面体自动旋转
3d·wpf
仙宇觉尘2 天前
WPF Stylet可以如何实现导航功能?
java·开发语言·wpf
hsw8157739432 天前
第10章 软件架构的演化和维护 — 系统架构设计师
unity·系统架构·游戏引擎