uFrame 1.6杂乱笔记与一些翻译

The Kernel
The Kernel是uFrame的本质,负责处理加载场景,系统和服务。

Subsystems
作为一个容器,组成许多Nodes。
Subsystems允许你分离项目中的逻辑部分和可复用部分。
System Loaders
System Loaders常用语初始化信息。

Node
Elements

  • 主要负责ViewModel(Unity中uFrame框架附带了Controller)部分
    For example, Player element could contain information about player properties like health, running speed, obtained weapons or
    actions; Shoot, TakeDamage or Die.
    一个Elements会创建对应的ViewModel和Controller类
    这里写图片描述

  • Inheritance(继承)

    如下图,可以连接两个elements,后者继承前者。 SettingsScreen Element will contain the IsActive property and Close command of its parent SubScreen.这里写图片描述

Views

  • 游戏中的表现层(数据来源与绑定ViewModel)。
    For instance, a PlayerView should probably exist on some kind of Player GameObject, and a PlayerHUDView should probably exist on some
    kind of GUI GameObject to bind to and express a player’s stats and
    other properties.

  • Important Methods(可以重写)
    All Views inherit from a ViewBase class. Here are the most important methods. You can override all of them.
    InitializeViewModel()
    View匹配ViewModel时的一些初始化。不勾选Initialize ViewModel则不被执行
    PreBind()
    This happens before the View begins creating bindings to its given ViewModel.
    Bind()
    This is where the View actually creates property bindings, collection bindings, and command bindings to the given ViewModel. The base.Bind() call will automatically create the bindings specified in the uFrame diagram for this specific View type.If you have any further manual bindings you need to do, this can be agood place to implement them.
    AfterBind()
    This is called immediately after the View creates bindings to its ViewModel.

  • Inspector options
    ViewModel Indentifier 关联的ViewModel的标识,可指定。
    Dispose On Destroy 若勾选上, View被销毁是,ViewModel也被销毁。
    Initialize ViewModel 是否自己来初始化ViewModel属性值。

  • Bindings
    每一个绑定都会生成对应的方法在ViewBase类里。
    有一些方法(TODO)

  • Execution Order
    For Views instantiated at runtime
    Awake > OnEnable > PreBind > Bind > AfterBind >InitializeViewModel > Start > Update loop begins
    For Views existing “SceneFirst” before runtime
    Awake > OnEnable > CreateModel > InitializeViewModel > Start (before base call) > PreBind > Bind >AfterBind > Start (after base call)
    When Destroying an object
    OnDisable > OnDestroy (before base.OnDestroy() call) >UnBind > OnDestroy (after base.OnDestroy() call)

View components

Enums

  • 用于定义新的属性类型给Elements使用。

Scene Types

  • 为了使用uFrame加载/卸载场景,必须使用Scene Types创建以便于给uFrame识别。
    可以定义怎样加载/卸载场景。
    可以多个场景共用一个Scene Types(有什么意义?案例中的选择关卡,多个关卡场景共用一个Scene Types)

  • Scene Types存在在一个场景的游戏入口,因为uFrame需要知道哪些场景被加载和保存 场景的引用,在需要移除场景时。

  • Scene Type Settings
    可以使用它来pass data给场景加载。

  • Generated Scene Types Scene Type是mono behaviour。让uFrame关联监听场景(当场景加载或被卸载时)。

  • Scene Loader
    一个Scene Type生成一个Scene Loader,交给uFrame Kernel管理。
    专门负责对应的Scene Type加载/卸载的一些功能。
    LoadScene() 对应 Unity’s LoadSceneAdditively()
    UnloadScene() 对应 the scene root game object is destroyed

  • Execution Order
    When you enter play mode, first executed will be the Start() method which is responsible for loading the kernel. You can override
    the KernelLoading() method to execute custom code before the kernel
    starts loading and the KernelLoaded() to execute custom code after
    the kernel finish loading.
    After the kernel is loaded, a SceneAwakeEvent is published. Read more in the Events page.
    SceneManagementService will receive this event, find a Scene Loader for the Scene Type and call its Load() coroutine.

Service Node

  • Service也是交给uFrame Kernel管理。
    可以写一些Commands和Events让Service订阅。
    字面上的意思,提供一些服务给其他节点。

Simple Classes(看文档)

  • 自定义的类。
    可作为Element的属性和command的参数。

Type References(看文档)

  • 可以指定新的类型在其他Nodes使用。
    不会被uFrame生成,要自己创建。
    一般在services配合handlers使用(大概)。

  • 自定义类型,不被uFrame创建

Command Node

  • 能被事件系统订阅。
    一般用来传递数据给Controller。

Computed Properties

  • 根据properties来计算得出另一些属性。比如血量少于0则得出死亡属性。

Element

  • ViewModels当需要时存在内存中。如果运行时View存在在场景中,它将会执行ViewCreatedEvent,ViewService将会匹配指定绑定的ViewModel,如果不存在则创建。大概只存在一个。

  • Creation And Initialization
    Creating a ViewModel with the Extension Method 在uframe 1.6中是通过额外的方法(使用正确的controller)创建ViewModel this.CreateViewModel()

Designer Overview

  • For instance, a PlayerView should probably exist on some kind of
    Player GameObject, and a PlayerHUDView should probably exist on some
    kind of GUI GameObject to bind to and express a player’s stats and
    other properties.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值