I’ve accidentally deleted the code for ActivateTrigger.cs (Unitron). Can someone post the original code to that document?
Any time you accidentally delete an asset from a standard asset package:
Go to menu Assets > Import Package >[Package the asset is in]
Click
Check off the box next to the asset you need to recover
Click
Done! It’s back.
I tried that but now i’ve got the following errors:
“Assets/Standard Assets/Scripts/General Scripts/ActivateTrigger.cs(1,23): error CS8025: Parsing error”,
“UnityEditor.SceneView.ShowCompileErrorNotification()”,
“UnityEditor.SceneView.ShowCompileErrorNotification()”,
“UnityEditor.SceneView.ShowCompileErrorNotification()”.
Can you post the first few lines of your ActivateTrigger.cs script?
I’m pretty sure that this is completely wrong.
using UnityEngine;
public class ActivateTrigger : MonoBehaviour {
public enum Mode {
Trigger = 0, // Just broadcast the action on to the target
Replace = 1, // replace target with source
Activate = 2, // Activate the target GameObject
Enable = 3, // Enable a component
Animate = 4, // Start animation on target
Deactivate= 5 // Decativate target GameObject
}
/// The action to accomplish
public Mode action = Mode.Activate;
/// The game object to affect. If none, the trigger work on this game object
public Object target;
public GameObject source;
public int triggerCount = 1;///
public bool repeatTrigger = false;
void DoActivateTrigger () {
triggerCount–;
if (triggerCount == 0 || repeatTrigger) {
Object currentTarget = target != null ? target : gameObject;
Behaviour targetBehaviour = currentTarget as Behaviour;
GameObject targetGameObject = currentTarget as GameObject;
if (targetBehaviour != null)
targetGameObject = targetBehaviour.gameObject;
switch (action) {
case Mode.Trigger:
targetGameObject.BroadcastMessage (“DoActivateTrigger”);
break;
case Mode.Replace:
if (source != null) {
Object.Instantiate (source, targetGameObject.transform.position, targetGameObject.transform.rotation);
DestroyObject (targetGameObject);
}
break;
case Mode.Activate:
targetGameObject.active = true;
break;
case Mode.Enable:
if (targetBehaviour != null)
targetBehaviour.enabled = true;
break;
case Mode.Animate:
targetGameObject.animation.Play ();
break;
case Mode.Deactivate:
targetGameObject.active[) = false;
break;
}
}
}
void OnTriggerEnter (Collider other) {
DoActivateTrigger ();
}
}
I am having the same problem. How is a script that comes with unity have so many errors…just spent the last hour cleaning this crap up.