zoukankan      html  css  js  c++  java
  • Unity3D TestTool Part _1

      一直想看看Unity3d官方推出的UnityTestTools的测试插件,今天有空尝试了一下。

     一、Quick Start

      1、 create a plane position which transform position is vector3 (0,0,0),attach a script name it hero.Content next:  

        public float Health = 100f;
    
        void OnCollisionEnter(Collision collision)
        {
            Health -= 10f;
            Destroy(collision.gameObject);
        }
    

      2、create a gameobject which transform position is vector3 (0,10,0), attach a script name it Spawn,Context next:

    // Use this for initialization
    	void Start () {
            InvokeRepeating("CreateRigidbody", 0f, 2f);
    	}
    
        void CreateRigidbody() {
            GameObject tmp = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            //不加位置默认(0,0,0)
            tmp.transform.position = transform.position;
            tmp.AddComponent<Rigidbody>();
            
        }
    

      3. Attach Assertin Component Script,set like next

      

         4.Now,Run you sence. When you hero's Health below 50 , there is a AssertionException: FloatComparer assertion failed.

       从上述看,这个解决了一些我们在Unity主线程调用函数的时候的一些逻辑判断。这样我们就不用在自己嵌入代码了。缺点就是如果场景太多,这些Component我们又不想要了,就有点麻烦了。

    二、Integration Test Runner

      1.Click Unity Test Tools -> Integration Test Runner. Click  Symbol '+' to create TestRunner.

          

      2.Let's do something. Create a Plane.you will find the plane auto be the child of New Test. Then Create a cube then attach component rigidbody.

      3.Last, you can attach  Call Testing Script ,Set Config like that .The config is means when the cube collide the plane ,the test runner suscess.

      

       4.可以测试在Unity主线程调用的一些函数。

     

  • 相关阅读:
    网页收藏
    background 和IMG的差异
    cefsharp开发实例1
    Node.js系列之node.js初探
    sublime3安装package controller遇到的问题
    java 指定日期加指定天数
    svn 命令
    mac下nodejs 更新到最新版本的最新方法
    mac系统安装redis
    sublime 安装插件
  • 原文地址:https://www.cnblogs.com/chongxin/p/3978079.html
Copyright © 2011-2022 走看看