当前位置: 首页>>代码示例>>C#>>正文


C# GameObject.GetValue方法代码示例

本文整理汇总了C#中GameObject.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.GetValue方法的具体用法?C# GameObject.GetValue怎么用?C# GameObject.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameObject的用法示例。


在下文中一共展示了GameObject.GetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PropertyConnection

        public void PropertyConnection()
        {
            GameObject.CreateProperty<float>("X", "Layout", "blah", 1);
              GameObject.CreateProperty<float>("Y", "Layout", "blah", 1);

              var a = new GameObject();
              var b = new GameObject();

              var aX = a.Properties.Get<float>("X");
              var bY = b.Properties.Get<float>("Y");
              aX.Changed += bY.Change;

              aX.Value = 22;
              Assert.AreEqual(22, b.GetValue<float>("Y"));

              aX.Changed -= bY.Change;
              aX.Value = 23;
              Assert.AreEqual(22, b.GetValue<float>("Y"));
        }
开发者ID:,项目名称:,代码行数:19,代码来源:

示例2: Template

        public void Template()
        {
            GameObject.CreateProperty<float>("X", "Layout", "blah", 0);
              GameObject.CreateProperty<float>("Y", "Layout", "blah", 0);
              GameObject.CreateProperty<float>("Z", "Layout", "blah", 0);
              GameObject.CreateProperty<float>("W", "Layout", "blah", 0);

              var t = new GameObject();

              t.SetValue("X", 10.0f);
              t.SetValue("Y", 20.0f);
              t.SetValue("Z", 30.0f);

              var a = new GameObject();

              Assert.AreEqual(0, a.GetValue<float>("X"));

              a.Template = t;

              Assert.AreEqual(10, a.GetValue<float>("X"));
              Assert.AreEqual(20, a.GetValue<float>("Y"));
              Assert.AreEqual(30, a.GetValue<float>("Z"));

              Assert.IsFalse(a.Properties.Get<float>("X").HasLocalValue);
              Assert.IsFalse(a.Properties.Get<float>("Y").HasLocalValue);
              Assert.IsFalse(a.Properties.Get<float>("Z").HasLocalValue);

              a.SetValue("Y", 999.0f);

              Assert.AreEqual(10, a.GetValue<float>("X"));
              Assert.AreEqual(999, a.GetValue<float>("Y"));
              Assert.AreEqual(30, a.GetValue<float>("Z"));

              Assert.IsFalse(a.Properties.Get<float>("X").HasLocalValue);
              Assert.IsTrue(a.Properties.Get<float>("Y").HasLocalValue);
              Assert.IsFalse(a.Properties.Get<float>("Z").HasLocalValue);

              a.Properties.Get<float>("Y").Reset();

              Assert.AreEqual(10, a.GetValue<float>("X"));
              Assert.AreEqual(20, a.GetValue<float>("Y"));
              Assert.AreEqual(30, a.GetValue<float>("Z"));

              Assert.IsFalse(a.Properties.Get<float>("X").HasLocalValue);
              Assert.IsFalse(a.Properties.Get<float>("Y").HasLocalValue);
              Assert.IsFalse(a.Properties.Get<float>("Z").HasLocalValue);

              // Enumerate properties.
              Assert.AreEqual(3, ((IEnumerable)a.Properties).Cast<IGameProperty>().Count());

              _wasCalled = false;
              a.TemplateChanged += (s, e) => _wasCalled = true;

              a.Template = t;
              Assert.IsFalse(_wasCalled);

              a.Template = null;
              Assert.IsTrue(_wasCalled);
        }
开发者ID:,项目名称:,代码行数:59,代码来源:

示例3: Properties

        public void Properties()
        {
            GameObject.CreateProperty<float>("X", "Layout", "blah", 0);
              GameObject.CreateProperty<string>("X", "Layout", "blah", string.Empty);
              GameObject.CreateProperty<bool>("IsEnabled", "Layout", "blah", false);

              var a = new GameObject("A");

              Assert.Throws(typeof(ArgumentException), () => a.GetValue<float>("Not defined"));

              Assert.AreEqual(0, a.GetValue<float>("X"));

              var p = a.Properties.Get<float>("X");
              Assert.AreEqual("X", p.Name);
              Assert.IsFalse(p.HasLocalValue);
              Assert.AreEqual(0, p.Value);

              p.Metadata.DefaultValue = 1;
              Assert.AreEqual(1, p.Value);

              p.Value = 2;
              Assert.AreEqual(2, p.Value);

              ((IGameProperty)p).Value = 3.0f;
              Assert.AreEqual(3, ((IGameProperty)p).Value);
              Assert.AreEqual(3, p.Value);
        }
开发者ID:,项目名称:,代码行数:27,代码来源:


注:本文中的GameObject.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。