返回介绍

Network.Destroy 销毁

发布于 2019-12-18 15:38:06 字数 2457 浏览 953 评论 0 收藏 0

JavaScript => public static function Destroy(viewID: NetworkViewID): void;
C# => public static void Destroy(NetworkViewID viewID);

Parameters 参数

Description 描述

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

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

The object is destroyed locally and remotely.

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

Note that this does not remove any RPCs accociated with the object or NetworkViewID, these have to be explicitly removed with the Network.RemoveRPCs method.

JavaScript:

var timer : float = 0;
	function Awake () {
		timer = Time.time;
	}
	// Network destroy the object which has this script
	// it must have a NetworkView attached
	function Update() {
		if (Time.time - timer > 2) {
			Network.Destroy(GetComponent.<NetworkView>().viewID);
		}
	}

C#:

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

public static void Destroy(GameObject gameObject);

Parameters 参数

Description 描述

Destroy the object across the network.

跨网络销毁该物体。

The object is destroyed locally and remotely.

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

JavaScript:

	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);
		}
	}

C#:

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

network

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文