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();

}

}

}

相关推荐
hqwest15 小时前
C#WPF实战出真汁06--【系统设置】--餐桌类型设置
c#·.net·wpf·布局·分页·命令·viewmodel
Vae_Mars17 小时前
WPF中使用InputBindings进行快捷键绑定
wpf
hqwest20 小时前
C#WPF实战出真汁05--左侧导航
开发语言·c#·wpf·主界面·窗体设计·视图viewmodel
hqwest1 天前
C#WPF实战出真汁01--项目介绍
开发语言·c#·wpf
wuty0072 天前
WPF 实现支持动态调整高度的文本显示控件
wpf·scrollviewer·extentheight·自动高度控件·动态调整高度
霜绛2 天前
Unity:GUI笔记(一)——文本、按钮、多选框和单选框、输入框和拖动条、图片绘制和框绘制
笔记·学习·unity·游戏引擎
YF云飞3 天前
Unity图片优化与比例控制全攻略
游戏·unity·游戏引擎·游戏程序·个人开发
4 天前
Unity 遮挡显示效果 Shader
unity·游戏引擎
向宇it4 天前
【unity实战】在Unity中实现不规则模型的网格建造系统(附项目源码)
游戏·3d·unity·c#·游戏引擎
范纹杉想快点毕业5 天前
C 语言主控开发与显控开发能力体系及技术栈详解,STM32、QT、嵌入式、边缘系统显示
stm32·单片机·tcp/ip·microsoft·fpga开发·51单片机·wpf