コード例 #1
0
 public NodeElem Component <PropT>(CompRender <PropT> render, PropT props)
     where PropT : struct
 {
     compElems[typeof(PropT)] = new CompElem <PropT>()
     {
         render = render, props = props
     };
     return(this);
 }
コード例 #2
0
    public IEnumerator CompElem()
    {
        CompElem compElem1 = new CompElem <TestComponent>(new TestComponent(value: 42));
        CompElem compElem2 = new CompElem <TestComponent>(new TestComponent(value: 7));
        var      obj       = new GameObject();

        compElem1.BuildComponent(null, obj);
        var monoBehaviour = obj.GetComponent <TestMonoBehaviour>();

        Assert.That(monoBehaviour, Is.Not.Null);
        Assert.That(monoBehaviour.value, Is.EqualTo(42));
        compElem2.BuildComponent(compElem1, obj);
        Assert.That(monoBehaviour.value, Is.EqualTo(7));
        compElem2.RemoveComponent(obj);
        yield return(null);

        Assert.That(obj.GetComponent <TestMonoBehaviour>(), Is.Null);
    }
コード例 #3
0
 public NodeElem Component <CompT>(CompT component) where CompT : struct, Component
 {
     compElems[typeof(CompT)] = new CompElem <CompT>(component);
     return(this);
 }