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

     

  • 相关阅读:
    【Gym
    [matlab工具箱] 曲线拟合Curve Fitting
    数学建模 常用
    “这么多人给我作证,我不怕”
    超星尔雅刷课辅助
    细思《都挺好》
    P5173 传球
    [ICPC 北京 2017 J题]HihoCoder 1636 Pangu and Stones
    CF 1131C Birthday
    CF 634A Island Puzzle
  • 原文地址:https://www.cnblogs.com/chongxin/p/3978079.html
Copyright © 2011-2022 走看看