Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/jackmawer/JacksWorld. An abandoned mini-project that I created while learning to use Unity with networking.
Something went wrong. Try again.
1.1 kB · 42 lines
C#
at master
12345678910111213141516171819202122232425262728293031323334353637383940414243using UnityEngine;using System.Collections;
public class OnClickInstantiate : MonoBehaviour{ public GameObject Prefab; public int InstantiateType; private string[] InstantiateTypeNames = {"Mine", "Scene"};
public bool showGui;
void OnClick() { if (PhotonNetwork.connectionStateDetailed != PeerState.Joined) { // only use PhotonNetwork.Instantiate while in a room. return; }
switch (InstantiateType) { case 0: PhotonNetwork.Instantiate(Prefab.name, InputToEvent.inputHitPos + new Vector3(0, 5f, 0), Quaternion.identity, 0); break; case 1: PhotonNetwork.InstantiateSceneObject(Prefab.name, InputToEvent.inputHitPos + new Vector3(0, 5f, 0), Quaternion.identity, 0, null); break; } }
void OnGUI() { if (showGui) { GUILayout.BeginArea(new Rect(Screen.width - 180, 0, 180, 50)); InstantiateType = GUILayout.Toolbar(InstantiateType, InstantiateTypeNames); GUILayout.EndArea(); } }
}