Skip to content

Instantly share code, notes, and snippets.

@smallrice45
smallrice45 / EventTriggerListener
Created May 24, 2018 03:34
Unity UI簡易拖曳跟隨
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class EventTriggerListener : UnityEngine.EventSystems.EventTrigger
{
public delegate void VoidDelegate(GameObject go);
public delegate void VoidDelegatePointer(GameObject go, Vector2 pos);
public VoidDelegate onClick;
public VoidDelegate onDown;
@smallrice45
smallrice45 / ParticelObjectPool
Created January 3, 2017 05:49
ParticelObjectPool
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ParticelObjectPool : MonoBehaviour {
private ParticleSystem _ParticleSystem;
private ParticleSystemRenderer _ParticleSystemRenderer;
private ParticleSystem.Particle[] _Particles;
public GameObject _ParticelObject;
private GameObject _ObjectPool;
@smallrice45
smallrice45 / AssetbundlesMenuItems
Created April 22, 2016 13:15
AssetBundle練習測試
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Linq;
using System.Collections.Generic;
public class AssetbundlesMenuItems
{
@smallrice45
smallrice45 / CharacterCustomizableCreateManager
Last active April 17, 2016 10:10
擴展 UGUI研究院之控件以及按钮的监听事件系统(五) 內文的Code
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
public class CharacterCustomizableCreateManager : MonoBehaviour {
public List<Toggle> sexToggleGroup;
public Slider hairSlider;
@smallrice45
smallrice45 / CharacterAttribute
Last active December 28, 2015 22:48
Unity 2D CharacterController
using UnityEngine;
using System.Collections;
using System;
public class CharacterAttribute : MonoBehaviour {
[Serializable]
public class CommonAttribute{
public float lifeTime;
public GameObject groundedOn = null;
public GameObject lastgroundedLadderGround = null;
@smallrice45
smallrice45 / DataSaveController
Last active December 11, 2015 04:55
UnityC#_DataSaveSystem
using UnityEngine;
using System.Collections;
public class DataSaveController : MonoBehaviour {
public int m_InstanceID;
// Use this for initialization
void Reset () {
m_InstanceID = gameObject.GetInstanceID();
}
void OnValidate() {
@smallrice45
smallrice45 / FirstPersonCamera
Created August 3, 2015 17:22
頭戴裝置FPS角色控制邏輯。
using UnityEngine;
using System.Collections;
public class FirstPersonCamera : MonoBehaviour {
public Transform m_Player;
public Transform m_Target;
public float direction;
// Update is called once per frame
void Update () {
@smallrice45
smallrice45 / DataManager
Created July 4, 2015 13:29
委託與監聽範本
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class DataManager : MonoBehaviour {
public delegate void DataLoaderHandler();
public event DataLoaderHandler onLoaderComplete;
void Start(){
DoSomething();
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class EventTriggerListener : UnityEngine.EventSystems.EventTrigger{
public delegate void VoidDelegate (GameObject go);
public delegate void VoidDelegateData (GameObject go, PointerEventData eventData);
public VoidDelegate onClick;
public VoidDelegate onDown;
public VoidDelegate onEnter;
public VoidDelegate onExit;
@smallrice45
smallrice45 / KeyboardEventListener
Created June 3, 2015 13:08
簡易2D角色控制
using UnityEngine;
using System.Collections;
public class KeyboardEventListener : MonoBehaviour {
public delegate void KeyboardHandler(int dir);
public event KeyboardHandler onHorizontalMove;
public event KeyboardHandler onVerticalMove;
private KeyCode m_LeftArrowKey = KeyCode.LeftArrow;