回调函数的作用通俗点讲就是完成了某个动作之后可以立马进行另一个动作,但那个动作你不确定具体会干什么,你可以根据不同的需求来进行不同的改变,这就是回调函数的作用
现在以一个很简单的例子来说明
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
public class TouchScreen : MonoBehaviour
{
private static Vector2 m_screenpos = new Vector2();
private static TouchScreen mInstance;
public Action<Vector2> OnTouchBegan;
public Action<Vector2 ,Vector2> OnTouchMove;
void Awake()
{
if(mInstance != null)
{
DestroyImmediate(mInstance);
mInstance = null;
}
mInstance = this;
}
void Update()
{
InitTouchScreen();
}
public static TouchScreen GetInstance()
{