mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-29 00:27:59 +01:00
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
|
using 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.inRoom)
|
||
|
{
|
||
|
// 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();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|