Difference between revisions of "CustomActivateTrigger"

From Headbone Creative
Jump to: navigation, search
(Initial page, includes API information and categories)
 
(Initial page, includes API information and categories)
 
Line 2: Line 2:
  
 
== Public Variables ==
 
== Public Variables ==
 
+
=== action : Mode ===
/// <summary>
+
This defines what happens when the trigger is activated. It can have the following values:
/// Trigger mode
+
==== Trigger ====
/// </summary>
+
Uses [http://docs.unity3d.com/Documentation/ScriptReference/GameObject.BroadcastMessage.html BroadcastMessage] to send a message to the '''target''' object.
public enum Mode {
+
==== Replace ====
Trigger  = 0, // Just broadcast the action on to the target
+
This destroys the '''target''' GameObject and instantiates a copy of the '''source''' object.
Replace   = 1, // replace target with source
+
==== Activate ====
Activate = 2, // Activate the target GameObject
+
This sets the [http://docs.unity3d.com/Documentation/ScriptReference/GameObject.SetActive.html active] flag of the '''target''' GameObject to true.
Enable   = 3, // Enable a component
+
==== Enable ====
Animate   = 4, // Start animation on target
+
If the '''target''' is a [http://docs.unity3d.com/Documentation/ScriptReference/Behaviour.html Behavior], this mode will enable it.
Deactivate= 5, // Decativate target GameObject
+
==== Animate ====
Broadcast = 6, // Broadcast the message using the messenger
+
This will call [http://docs.unity3d.com/Documentation/ScriptReference/Animation.Play.html Play] on the animation component attached to the '''target''' GameObject.
Spawn    = 7, // Spawn the source object at the target
+
==== Deactivate ====
}
+
This sets the [http://docs.unity3d.com/Documentation/ScriptReference/GameObject.SetActive.html active] flag of the '''target''' GameObject to false.
+
==== Broadcast ====
/// <summary>
+
This sends the message using [[Messenger#void_Broadcast.28string_eventType.29|Messenger.Broadcast]].
/// The action.
+
==== Spawn ====
/// </summary>
+
This will spawn an instance of the '''source''' object at the '''target''''s location
public Mode action = Mode.Activate;
+
=== 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.
/// <summary>
+
=== source : GameObject ===
/// The game object to affect. If none, the trigger work on this game object
+
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.  
/// </summary>
+
=== triggerCount : int ===
public Object target;
+
This is how many times the trigger must be hit before the action is performed.  
+
=== repeatTrigger : bool ===
/// <summary>
+
If this is set to true, the action will be performed every time the trigger is hit.
/// The source.
+
=== message : string ===
/// </summary>
+
This is the message that is sent from the Broadcast or Trigger modes.  
public GameObject source;
+
=== 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.
/// <summary>
+
=== runOnCollision : bool ===
/// The trigger count.
+
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.
/// </summary>
+
public int triggerCount = 1;
+
+
/// <summary>
+
/// The repeat trigger.
+
/// </summary>
+
public bool repeatTrigger = false;
+
+
/// <summary>
+
/// The message.
+
/// </summary>
+
public string message = "DoActivateTrigger";
+
+
/// <summary>
+
/// The run on trigger flag
+
/// </summary>
+
public bool runOnTrigger = true;
+
+
/// <summary>
+
/// The run on collision flag
+
/// </summary>
+
public bool runOnCollision = false;
+
  
  

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.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox