如何判断一个物体下是否有子物体?getchild(0)!=null?显然不可取 那去获取拿到子物体数量?transform.GetChildCount();可以解决 但在新版本中已被弃用,可用transform.childCount来直接获取子物体数量. using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Example() { print(transform.
记一次主线程等待子线程结束的多种方法的学习 在学习多线程时,最开始遇到的问题其实是"计算子线程运行时间",写到最后发现本文和标题更为符合,但是仍然基于问题:"在主线程中获取子线程的运行时间". while循环 对于"主线程如何获取子线程总运行时间"的问题,最开始想到的是使用while循环进行轮询: Thread t = new Thread(() -> { //子线程进行字符串连接操作 int num = 1000; String s =
原子线程调用Toast报Can't create handler inside thread that has not called Looper.prepare() 错误 今天用子线程调Toast报了一个Can't create handler inside thread that has not calledLooper.prepare()错误. 因为toast的实现需要在activity的主线程才能正常工作,所以传统的非主线程不能使toast显示在actvity上,通过Handler可以使