Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity c# on trigger

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerTester : MonoBehaviour
{
    private void OnTriggerEnter(Collider other)
    {
        Debug.LogFormat("{0} trigger enter: {1}", this, other);
    }
    private void OnTriggerStay(Collider other)
    {
        Debug.LogFormat("{0} trigger stay: {1}", this, other);
    }
    private void OnTriggerExit(Collider other)
    {
        Debug.LogFormat("{0} trigger exit: {1}", this, other);
    }
}
Comment

on trigger stay unity

private void OnTriggerStay(Collider other)
{
	// Do some stuff
}
Comment

On Trigger Unity

"          |  Static   |  Dynamic  | Kinematic |  Static  |  Dynamic  | Kinematic |"
"          |           |           |           |  Trigger |  Trigger  |  Trigger  |"
----------------------------------------------------------------------------------
" Static  "|           | Collision |           |          |  Trigger  |  Trigger  |
"         "|           |           |           |          |           |           |
----------------------------------------------------------------------------------
" Dynamic "| Collision | Collision | Collision |  Trigger |  Trigger  |  Trigger  |
"         "|           |           |           |          |           |           |
----------------------------------------------------------------------------------
"Kinematic"|           | Collision |           |  Trigger |  Trigger  |  Trigger  |
"         "|           |           |           |          |           |           |
----------------------------------------------------------------------------------
" Static  "|           |  Trigger  |  Trigger  |          |  Trigger  |  Trigger  |
" Trigger "|           |           |           |          |           |           |
----------------------------------------------------------------------------------
" Dynamic "|  Trigger  |  Trigger  |  Trigger  |  Trigger |  Trigger  |  Trigger  |
" Trigger "|           |           |           |          |           |           |
----------------------------------------------------------------------------------
"Kinematic"|  Trigger  |  Trigger  |  Trigger  |  Trigger |  Trigger  |  Trigger  |
" Trigger "|           |           |           |          |           |           |
----------------------------------------------------------------------------------

// This shows how 2 objects (both having a rigidbody component) interact.
// Empty => They don't interact
// Collision => You can use OnColisionXXX
// Trigger => You can use OnTriggerXXX

//Hope it helps <3
Comment

unity event trigger

using UnityEngine;
using UnityEngine.EventSystems;

public class EventTriggerExample : EventTrigger
{
	public override void OnBeginDrag( PointerEventData data )
	{
		Debug.Log( "OnBeginDrag called." );
	}

	public override void OnCancel( BaseEventData data )
	{
		Debug.Log( "OnCancel called." );
	}

	public override void OnDeselect( BaseEventData data )
	{
		Debug.Log( "OnDeselect called." );
	}

	public override void OnDrag( PointerEventData data )
	{
		Debug.Log( "OnDrag called." );
	}

	public override void OnDrop( PointerEventData data )
	{
		Debug.Log( "OnDrop called." );
	}

	public override void OnEndDrag( PointerEventData data )
	{
		Debug.Log( "OnEndDrag called." );
	}

	public override void OnInitializePotentialDrag( PointerEventData data )
	{
		Debug.Log( "OnInitializePotentialDrag called." );
	}

	public override void OnMove( AxisEventData data )
	{
		Debug.Log( "OnMove called." );
	}

	public override void OnPointerClick( PointerEventData data )
	{
		Debug.Log( "OnPointerClick called." );
	}

	public override void OnPointerDown( PointerEventData data )
	{
		Debug.Log( "OnPointerDown called." );
	}

	public override void OnPointerEnter( PointerEventData data )
	{
		Debug.Log( "OnPointerEnter called." );
	}

	public override void OnPointerExit( PointerEventData data )
	{
		Debug.Log( "OnPointerExit called." );
	}

	public override void OnPointerUp( PointerEventData data )
	{
		Debug.Log( "OnPointerUp called." );
	}

	public override void OnScroll( PointerEventData data )
	{
		Debug.Log( "OnScroll called." );
	}

	public override void OnSelect( BaseEventData data )
	{
		Debug.Log( "OnSelect called." );
	}

	public override void OnSubmit( BaseEventData data )
	{
		Debug.Log( "OnSubmit called." );
	}

	public override void OnUpdateSelected( BaseEventData data )
	{
		Debug.Log( "OnUpdateSelected called." );
	}
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: C# Bitwise Right Shift 
Csharp :: linq find object from id 
Csharp :: C# compare date values 
Csharp :: instantiate prefab unity 
Csharp :: c# listview add item 
Csharp :: c# linq to select even numbers 
Csharp :: ? operator 
Csharp :: convert object to iqueryable in c# 
Csharp :: unity list get item at index 
Csharp :: declare enum c# 
Csharp :: ignore ssl c# 
Csharp :: c# how to append in array 
Csharp :: add list to list c# 
Csharp :: unity c# move transform 
Csharp :: fluent api 
Csharp :: calculator in c# 
Csharp :: c# object list to joined string 
Csharp :: c# convert date to oracle format 
Csharp :: .net on vs code 
Csharp :: how to cut a string in c# 
Csharp :: how to update model in entity framework db first approach 
Csharp :: run dll file 
Csharp :: monogame print 
Csharp :: display array elemetns to text box c# 
Csharp :: flat view player movement script 
Csharp :: asp net c# browser cursor wait 
Csharp :: print hello world in unity 
Csharp :: how to call an If statement only once in C# 
Csharp :: wpf StrokeDashArray 
Csharp :: w3develops 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =