//定义函数private Vector3 CenterPoint(){Vector3 point = new Vector3 ();foreach (Transform GameObject in GameObjects){point += GameObject.position;}point = point / GameObjects.Length;return point;}//使用函数private void Start(){Vector3 centerPoint = CenterPoint();//使用函数的返回值}
//设定函数private void SetHealth(float a){health.value = a;}//使用函数private void Start(){SetHealth(60);//传入参数并引用}
