现在 正在做unity的方向 不得不说我选的是UI方向 Unity中很有名的就是NGUI插件了.今天做了个ngui的简单背包系统。非常简陋。。初学着 自己mark下

(1)预览

主要就是个 simple popup list控件(为label制作动态字体方便支持中文)

设置如图

mark为空物体,作为动态生成的图集的坐标。为他绑定脚本 child:

using UnityEngine;
using System.Collections; public class child : MonoBehaviour { // Use this for initialization
void Start () { } // Update is called once per frame
void Update () {
Transform[] chinds = this.GetComponentsInChildren<Transform>();
if (chinds.Length >= )
{ Destroy(chinds[].gameObject); } }
}

camera得脚本:

 using UnityEngine;
using System.Collections; public class load_sprite : MonoBehaviour
{
public GameObject parent;
private UIDragObject ud;
// Use this for initialization
void Start()
{ } // Update is called once per frame
void Update()
{
parent.transform.position = new Vector3(-1.782f, -0.29f, );
}
public void create()
{
UIAtlas atlas = (UIAtlas)Resources.Load("Atlas/New Atlas_1", typeof(UIAtlas));
UISprite sprite = NGUITools.AddSprite(parent, atlas, UIPopupList.current.value);
sprite.transform.localScale = new Vector3(2.0f, 2.0f, 2.0f);
sprite.transform.localPosition = Vector3.zero;
sprite.gameObject.AddComponent<BoxCollider>().size=new Vector3(,,);
sprite.gameObject.AddComponent<Drop_PM>();
sprite.tag = "item";
sprite.depth = ; GameObject go = GameObject.Find("Sprite");
BoxCollider col = go.AddComponent<BoxCollider>();
col.size = new Vector3(, , );
go.AddComponent<UIDragDropItem>();
go.GetComponent<UIWidget>().depth = ; }
}

project视图(必须为Resources,内放图集)

还有个动态加载的脚本 重写uidragdropitem

 using UnityEngine;
using System.Collections; public class MyDragItem : UIDragDropItem { protected override void OnDragDropRelease(GameObject surface)
{
base.OnDragDropRelease(surface); print(surface); this.transform.parent = surface.transform;
this.transform.localPosition = Vector3.zero;
}
}

很简单的一个入门实验。

最新文章

  1. MVC5 网站开发实践 2.2、管理员身份验证
  2. RSA的傻瓜原理
  3. 【BZOJ】1179: [Apio2009]Atm(tarjan+spfa)
  4. 请让页面中的一个元素(10px*10px)围绕坐标(200, 300) 做圆周运动
  5. ext 金额大写
  6. Mac Java maven环境变量
  7. mongoDB5--mongoDB增删改查
  8. Servlet(2)
  9. NSArray NSMutableArray
  10. Lodop获取全部JS代码,传统JS模版的生成
  11. markdown自动生成侧边栏TOC /目录
  12. android -------- 打开本地浏览器或指定浏览器加载,打电话,打开第三方app
  13. vue引用样式
  14. qt书籍推荐
  15. 文件名命工具类(将指定目录下的文件的type类型的文件,进行重命名,命名后的文件将去掉type)
  16. grunt入门讲解3:实例讲解使用 Gruntfile 配置任务
  17. 牛客红包OI赛 C 小可爱表白
  18. OpenERP7.0安装后提示&ldquo;not supported&quot; ,如何去掉此提示
  19. Centos下查看和修改网卡Mac地址
  20. Android 之WebView实现下拉刷新和其他相关刷新功能

热门文章

  1. ListView优化分页优化
  2. 手势识别=读取手机联系人=ContentResolver-Day3
  3. javascript - 图片的幻灯片效果
  4. iOS崩溃报告获取一
  5. Linux下追踪函数调用,打印栈帧
  6. 从Bash漏洞学Shell脚本(冒号)
  7. centos下配置多个tomcat同时运行
  8. web版扫雷小游戏(三)
  9. 【开源】封装HTML5的localstorage
  10. opencart 百度登录和百度钱包支付插件 响应式适应pc/mobile