Skip to content

Instantly share code, notes, and snippets.

public void MyFunction(){...}
public void MyFunction(float parameter){...}
public void MyFunction(int parameter){...}
public void MyFunction(string parameter){...}
public void MyFunction(bool parameter){...}
public void MyFunction(Object parameter){...}
using UnityEngine;
using System.Collections;
public class ButtonEvent : MonoBehaviour {
public void ClickButtonEvent(){
transform.position = new Vector3 (0, 5, 0);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class OnClickBtnScript : MonoBehaviour {
public Button btn;
void Start () {
btn.onClick.AddListener (OnClickBtnCallback);
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class EventTriggerEx : 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." );}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class EventTriggerDelegateEx : MonoBehaviour
{
void Start( )
{
EventTrigger trigger = GetComponent<EventTrigger>( );
EventTriggerType.PointerEnter //IPointerEnterHandler.OnPointerEnter をフックする。
EventTriggerType.PointerExit //IPointerExitHandler.OnPointerExit をフックする。
EventTriggerType.PointerDown //IPointerDownHandler.OnPointerDown をフックする。
EventTriggerType.PointerUp //IPointerUpHandler.OnPointerUp をフックする。
EventTriggerType.PointerClick //IPointerClickHandler.OnPointerClick をフックする。
EventTriggerType.Drag //IDragHandler.OnDrag をフックする。
EventTriggerType.Drop //IDropHandler.OnDrop をフックする。
EventTriggerType.Scroll //IScrollHandler.OnScroll をフックする。
EventTriggerType.UpdateSelected //IUpdateSelectedHandler.OnUpdateSelected をフックする。
EventTriggerType.Select //ISelectHandler.OnSelect をフックする。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Health : MonoBehaviour {
public Slider slider;
void Update () {
//1秒間に0.5増加する速度でスライダーの値を1まで動かす
@n-taku
n-taku / ArchedText.cs
Last active August 16, 2021 07:44
TextMeshProでAnimationのカーブに沿って文字を並べる
using UnityEngine;
using TMPro;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif
[ExecuteInEditMode]
public class ArchedText : MonoBehaviour
@n-taku
n-taku / CurvedText.cs
Last active June 2, 2023 10:56
TextMeshProでAnimationのカーブに沿って文字を並べる
using UnityEngine;
using TMPro;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif
[ExecuteInEditMode]
public class CurvedText : MonoBehaviour
@n-taku
n-taku / SafeAreaBounds.cs
Last active December 7, 2018 12:38
uGUIでのiPhoneXの対応
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SafeAreaBounds : MonoBehaviour
{
private RectTransform target;
#if UNITY_EDITOR
public bool emulateIPhoneX = false;