unity集成到安卓中:
https://blog.csdn.net/AllBluefm/article/details/155519181
unity调用安卓方法:
https://blog.csdn.net/AllBluefm/article/details/155520724
安卓调用unity中的方法,比如点击安卓上一个按钮,启动unity中一个动画
第一步:unity中需要写好脚本,并挂载到一个gameObject上,供安卓调用
using UnityEngine;
public class AnimationControl : MonoBehaviour
{
private Animation anim;
private string clipName = "Scene";
void Start()
{
anim = GetComponent<Animation>();
}
void Update()
{
}
// 播放动画,供安卓调用
public void Play()
{
anim[clipName].time = 0f;
anim[clipName].speed = 1f;
anim.Play(clipName, PlayMode.StopSameLayer);
}
}
第二步:在安卓中调用
// 播放动画
UnityPlayer.UnitySendMessage("model", "Play", "");
第一个参数:unity中AnimationControl 脚本挂载的gameObject名称
第二个参数:调用的方法
第三个参数:需要传到unity中的参数