Синтаксис:
Используется csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PliersPickup : MonoBehaviour {
bool enter = false;
public AudioSource pickFX;
public AudioClip pickfx;
public GameObject BackyardKey;
public GameObject Pliers;
public Transform SpawnPos;
public GameObject BackyardKeyObj;
public GameObject EPI;
public GameObject Code1;
public GameObject Code2;
public GameObject CodeDone;
public GameObject Code1Obj;
public GameObject Code2Obj;
public GameObject CodeDoneObj;
public GameObject Hammer;
public GameObject HammerObj;
public GameObject MainDoorKey;
public GameObject MainDoorKeyObj;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.E) && enter)
{
pickFX.PlayOneShot(pickfx);
EPI.GetComponent<ElectroPanelInteract>().closed = false;
if (BackyardKey.active == true)
{
BackyardKey.SetActive(false);
Instantiate(BackyardKeyObj, SpawnPos.position, Quaternion.identity);
}
else if (Code1.active == true)
{
Code1.SetActive(false);
Instantiate(Code1Obj, SpawnPos.position, Quaternion.identity);
}
else if (Code2.active == true)
{
Code2.SetActive(false);
Instantiate(Code2Obj, SpawnPos.position, Quaternion.identity);
}
else if (CodeDone.active == true)
{
CodeDone.SetActive(false);
Instantiate(CodeDoneObj, SpawnPos.position, Quaternion.identity);
}
else if (Hammer.active == true)
{
Hammer.SetActive(false);
Instantiate(HammerObj, SpawnPos.position, Quaternion.identity);
}
else if (MainDoorKey.active == true)
{
MainDoorKey.SetActive(false);
Instantiate(MainDoorKeyObj, SpawnPos.position, Quaternion.identity);
}
Pliers.SetActive(true);
Destroy(gameObject);
}
}
void OnGUI()
{
if (enter)
{
GUI.Label(new Rect(Screen.width / 2 - 15, Screen.height - 100, 150, 30), "Cutting Pliers (E)");
}
}
// Activate the Main function when Player enter the trigger area
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
enter = true;
}
}
void OnTriggerExit(Collider other)
{
if (other.CompareTag("Player"))
{
enter = false;
}
}
}
using System.Collections.Generic;
using UnityEngine;
public class PliersPickup : MonoBehaviour {
bool enter = false;
public AudioSource pickFX;
public AudioClip pickfx;
public GameObject BackyardKey;
public GameObject Pliers;
public Transform SpawnPos;
public GameObject BackyardKeyObj;
public GameObject EPI;
public GameObject Code1;
public GameObject Code2;
public GameObject CodeDone;
public GameObject Code1Obj;
public GameObject Code2Obj;
public GameObject CodeDoneObj;
public GameObject Hammer;
public GameObject HammerObj;
public GameObject MainDoorKey;
public GameObject MainDoorKeyObj;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.E) && enter)
{
pickFX.PlayOneShot(pickfx);
EPI.GetComponent<ElectroPanelInteract>().closed = false;
if (BackyardKey.active == true)
{
BackyardKey.SetActive(false);
Instantiate(BackyardKeyObj, SpawnPos.position, Quaternion.identity);
}
else if (Code1.active == true)
{
Code1.SetActive(false);
Instantiate(Code1Obj, SpawnPos.position, Quaternion.identity);
}
else if (Code2.active == true)
{
Code2.SetActive(false);
Instantiate(Code2Obj, SpawnPos.position, Quaternion.identity);
}
else if (CodeDone.active == true)
{
CodeDone.SetActive(false);
Instantiate(CodeDoneObj, SpawnPos.position, Quaternion.identity);
}
else if (Hammer.active == true)
{
Hammer.SetActive(false);
Instantiate(HammerObj, SpawnPos.position, Quaternion.identity);
}
else if (MainDoorKey.active == true)
{
MainDoorKey.SetActive(false);
Instantiate(MainDoorKeyObj, SpawnPos.position, Quaternion.identity);
}
Pliers.SetActive(true);
Destroy(gameObject);
}
}
void OnGUI()
{
if (enter)
{
GUI.Label(new Rect(Screen.width / 2 - 15, Screen.height - 100, 150, 30), "Cutting Pliers (E)");
}
}
// Activate the Main function when Player enter the trigger area
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
enter = true;
}
}
void OnTriggerExit(Collider other)
{
if (other.CompareTag("Player"))
{
enter = false;
}
}
}
Буду благодарен если поможете.