Network.Destroy 销毁

static function Destroy (viewID : NetworkViewID) : void

Description描述

Destroy the object associated with this view ID across the network.

跨网络销毁与该viewID相关的物体。

The object is destroyed locally and remotely.

本地的和远端的都会被销毁。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public float timer = 0;
	void Awake() {
		timer = Time.time;
	}
	void Update() {
		if (Time.time - timer > 2)
			Network.Destroy(GetComponent<NetworkView>().viewID);

	}
}
var timer : float = 0;
function Awake () {
	timer = Time.time;
}
// Network destroy the object which has this script
// it must have a NetworkView attached
//通过网络销毁拥有该脚本的物体,必须具备NetworkView属性
function Update() {
	if (Time.time - timer > 2) {
		Network.Destroy(GetComponent(NetworkView).viewID);
	}
}

• static function Destroy (gameObject : GameObject) : void

Description描述

Destroy the object across the network.

跨网络销毁该物体。

The object is destroyed locally and remotely.

本地的和远端的都会被销毁。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public float timer = 0;
	void Awake() {
		timer = Time.time;
	}
	void Update() {
		if (Time.time - timer > 2)
			Network.Destroy(gameObject);

	}
}
var timer : float = 0;
function Awake () {
	timer = Time.time;
}
// Network destroy the object which has this script
//网络销毁具有该脚本的物体
function Update() {
	if (Time.time - timer > 2) {
		Network.Destroy(gameObject);
	}
}
Page last updated: 2011-4-4