Difference between revisions of "CustomActivateTrigger"
(Initial page, includes API information and categories) |
(Initial page, includes API information and categories) |
||
Line 2: | Line 2: | ||
== Public Variables == | == Public Variables == | ||
− | + | === action : Mode === | |
− | + | This defines what happens when the trigger is activated. It can have the following values: | |
− | + | ==== Trigger ==== | |
− | + | Uses [http://docs.unity3d.com/Documentation/ScriptReference/GameObject.BroadcastMessage.html BroadcastMessage] to send a message to the '''target''' object. | |
− | + | ==== Replace ==== | |
− | + | This destroys the '''target''' GameObject and instantiates a copy of the '''source''' object. | |
− | + | ==== Activate ==== | |
− | + | This sets the [http://docs.unity3d.com/Documentation/ScriptReference/GameObject.SetActive.html active] flag of the '''target''' GameObject to true. | |
− | + | ==== Enable ==== | |
− | + | If the '''target''' is a [http://docs.unity3d.com/Documentation/ScriptReference/Behaviour.html Behavior], this mode will enable it. | |
− | + | ==== Animate ==== | |
− | + | This will call [http://docs.unity3d.com/Documentation/ScriptReference/Animation.Play.html Play] on the animation component attached to the '''target''' GameObject. | |
− | + | ==== Deactivate ==== | |
− | + | This sets the [http://docs.unity3d.com/Documentation/ScriptReference/GameObject.SetActive.html active] flag of the '''target''' GameObject to false. | |
− | + | ==== Broadcast ==== | |
− | + | This sends the message using [[Messenger#void_Broadcast.28string_eventType.29|Messenger.Broadcast]]. | |
− | + | ==== Spawn ==== | |
− | + | This will spawn an instance of the '''source''' object at the '''target''''s location | |
− | + | === target : Object === | |
− | + | This is the object to affect. It can be a GameObject or MonoBehaviour. If not set, it will default to the object to which the object is attached to. | |
− | + | === source : GameObject === | |
− | + | This must be set for the Spawn and Replace modes to do anything. Generally, it is set to a prefab that will be spawned into the scene. | |
− | + | === triggerCount : int === | |
− | + | This is how many times the trigger must be hit before the action is performed. | |
− | + | === repeatTrigger : bool === | |
− | + | If this is set to true, the action will be performed every time the trigger is hit. | |
− | + | === message : string === | |
− | + | This is the message that is sent from the Broadcast or Trigger modes. | |
− | + | === runOnTrigger : bool === | |
− | + | If true, the action is performed when [http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnTriggerEnter.html OnTriggerEnter] is called on the object the script is attached to. | |
− | + | === runOnCollision : bool === | |
− | + | If true, the action is performed when [http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnCollisionEnter.html OnCollisionEnter] is called on the object the script is attached to. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
Latest revision as of 04:37, 20 April 2013
This is an enhanced version of the ActivateTrigger script included with Unity's Standard Assets.
Contents |
[edit] Public Variables
[edit] action : Mode
This defines what happens when the trigger is activated. It can have the following values:
[edit] Trigger
Uses BroadcastMessage to send a message to the target object.
[edit] Replace
This destroys the target GameObject and instantiates a copy of the source object.
[edit] Activate
This sets the active flag of the target GameObject to true.
[edit] Enable
If the target is a Behavior, this mode will enable it.
[edit] Animate
This will call Play on the animation component attached to the target GameObject.
[edit] Deactivate
This sets the active flag of the target GameObject to false.
[edit] Broadcast
This sends the message using Messenger.Broadcast.
[edit] Spawn
This will spawn an instance of the source object at the target's location
[edit] target : Object
This is the object to affect. It can be a GameObject or MonoBehaviour. If not set, it will default to the object to which the object is attached to.
[edit] source : GameObject
This must be set for the Spawn and Replace modes to do anything. Generally, it is set to a prefab that will be spawned into the scene.
[edit] triggerCount : int
This is how many times the trigger must be hit before the action is performed.
[edit] repeatTrigger : bool
If this is set to true, the action will be performed every time the trigger is hit.
[edit] message : string
This is the message that is sent from the Broadcast or Trigger modes.
[edit] runOnTrigger : bool
If true, the action is performed when OnTriggerEnter is called on the object the script is attached to.
[edit] runOnCollision : bool
If true, the action is performed when OnCollisionEnter is called on the object the script is attached to.