Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class PickUp : MonoBehaviour
{
public static string ObjectName;
void OnGUI()
{
{
GUI.Box(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 10, 200, 20), "Вы подняли " + ObjectName);
}
}
}
using System.Collections;
public class PickUp : MonoBehaviour
{
public static string ObjectName;
void OnGUI()
{
{
GUI.Box(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 10, 200, 20), "Вы подняли " + ObjectName);
}
}
}
повесил его на пустышку, потом написал еще один:
Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class Bullets : MonoBehaviour
{
public float time;
void OnTriggerEnter()
{
if (Statics.CurC < Statics.NeedC)
{
time = 4.0f;
if (time > 0)
{
time -= Time.deltaTime;
Statics.CurC++;
PickUp.ObjectName = "Патроны";
GameObject.FindGameObjectWithTag("PickUp").GetComponent("PickUp").active = true;
}
else
{
GameObject.FindGameObjectWithTag("PickUp").GetComponent("PickUp").active = false;
}
Destroy(gameObject);
}
}
}
using System.Collections;
public class Bullets : MonoBehaviour
{
public float time;
void OnTriggerEnter()
{
if (Statics.CurC < Statics.NeedC)
{
time = 4.0f;
if (time > 0)
{
time -= Time.deltaTime;
Statics.CurC++;
PickUp.ObjectName = "Патроны";
GameObject.FindGameObjectWithTag("PickUp").GetComponent("PickUp").active = true;
}
else
{
GameObject.FindGameObjectWithTag("PickUp").GetComponent("PickUp").active = false;
}
Destroy(gameObject);
}
}
}
повесил его на круг, круг исчезает при входе в него, если сразу включить скрипт "PickUp" то надпись меняется с "Вы подняли" на "Вы подняли патроны", но скрипт не выключается и переменная "time" не меняется на 4. Что не так я сделал?