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

}

}

}

相关推荐
jtymyxmz1 小时前
《Unity Shader》12.6 运动模糊
unity·游戏引擎
jtymyxmz4 小时前
《Unity Shader》12.4.2 实现
unity·游戏引擎
sindyra6 小时前
Unity UGUI 之 Canvas Scaler
unity·游戏引擎
500847 小时前
鸿蒙 Flutter 权限管理进阶:动态权限、权限组、兼容处理与用户引导
flutter·华为·架构·wpf·开源鸿蒙
500849 小时前
鸿蒙 Flutter 蓝牙与 IoT 开发进阶:BLE 设备连接、数据交互与设备管理
flutter·华为·electron·wpf·开源鸿蒙
Macbethad9 小时前
工业设备系统管理程序技术方案
大数据·wpf
程序猿阿伟10 小时前
《突破Unity热更新瓶颈:底层函数调用限制与生态适配秘籍》
unity·游戏引擎
5008412 小时前
鸿蒙 Flutter 混合栈开发:与 React Native/ArkTS 页面无缝集成(2025 爆火方案)
flutter·华为·electron·wpf·开源鸿蒙
龙智DevSecOps解决方案12 小时前
Perforce《2025游戏技术现状报告》Part 3:不同行业挑战以及Unreal、Godot、自研游戏引擎的应用趋势
游戏引擎·godot·游戏开发·perforce
jtymyxmz1 天前
《Unity Shader》12.2调整屏幕的亮度、饱和度和对比度
unity·游戏引擎