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主线程调用的一些函数。

     

  • 相关阅读:
    Quartz任务调度(3)存储与持久化操作配置详细解
    Quartz任务调度(2)CronTrigger定制个性化调度方案
    Quartz任务调度(1)概念例析快速
    Mybatis Generator最完整配置详解
    SpringMVC之@ControllerAdvice
    文件上传api——MultipartFile
    Springboot使用MatrixVariable 注解
    p命名空间和c命名空间
    SpringBoot配置Cors跨域请求
    SpringBoot五步配置Mybatis
  • 原文地址:https://www.cnblogs.com/chongxin/p/3978079.html
Copyright © 2011-2022 走看看