多人游戏需要用到聊天框,那么单机游戏 聊天框气泡 可以应用 在 拾取 物品提示,击杀提示上面。
本文根据参考资料6,来进行 的 图文 的 布局排列的设置。用代码实现,只说下思路。Unity 2018.1.3f1(64bit)
用按钮来触发 左边气泡,和右边气泡的效果。
using UnityEngine;
public class Test_Bubble : MonoBehaviour {
public GameObject selfGO;//self的预制体
public GameObject otherGO;//other的预制体
public GameObject parent;//设置父物体
public void createSelfGO()
{
createGO(selfGO, parent);
}
public void createOtherGO()
{
createGO(otherGO, parent);
}
private void createGO(GameObject go,GameObject parent)
{
if (go != null
&& parent != null
)
{
GameObject go_ = (GameObject)GameObject.Instantiate(go);
go_.transform.parent = parent.transform;
}
}
}
参考资料:
项目地址:TextInlineSprite
2.聊天功能,实现:每增加一条消息整体往上移动,滚动查看聊天记录
5.Unity3D Note7——使用UI系统与动画实现简单对话泡泡
工程下载:http://pan.baidu.com/s/1hrMxwf6 密码:6bss
7.