zoukankan      html  css  js  c++  java
  • UGUI学习笔记

    基本情况:熟悉NGUI  没接触过UGUI

    目标:熟练掌握UGUI,并用在实际项目中

    一 在网上寻找视频教程,快速了解UGUI

    http://www.taikr.com/course/89

    不错的视频,用来做入门不错

    二 在宣雨松的UGUI栏目中各种文章,在实际项目中会有相当大的参考性

    http://www.xuanyusong.com/archives/category/unity/%E3%80%90ugui%E7%A0%94%E7%A9%B6%E9%99%A2%E3%80%91

    --------------------------------------  -------------------------------------

    --------------------------------------------------------------------------------

    using UnityEngine;
    using System.Collections;
    using UnityEditor;
    using System.IO;
    
    public class MakeAtlas  {
         
        
        [MenuItem ("MyMenu/AtlasMaker")]
        static private void MakeAtlas1()
        {
            /*
             * Q:UGUI的图片没有在resource文件下不会被打包到apk中
             * A:采用宣雨松的方法  将每个图片建一个prefab索引  改进:创建对应的文件夹
             */
            string spriteDir = Application.dataPath + "/Resources/ItemPrefab";
            
            if(!Directory.Exists(spriteDir)){
                Directory.CreateDirectory(spriteDir);
            }
    
            DirectoryInfo rootDirInfo = new DirectoryInfo(Application.dataPath + "/_UITexture/UI/_ItemTexture");
            foreach (DirectoryInfo dirInfo in rootDirInfo.GetDirectories()) {
    
    
                string subDirePath = spriteDir + "/"+ dirInfo.Name;
    
                if (!Directory.Exists(subDirePath))
                {
                    Directory.CreateDirectory(subDirePath);
                }
    
                foreach (FileInfo pngFile in dirInfo.GetFiles("*.png", SearchOption.AllDirectories))
                {
                    string allPath = pngFile.FullName;
                    string assetPath = allPath.Substring(allPath.IndexOf("Assets"));
                    Sprite sprite = Resources.LoadAssetAtPath<Sprite>(assetPath);
                    GameObject go = new GameObject(sprite.name);
                    go.AddComponent<SpriteRenderer>().sprite = sprite;
    
                    allPath = subDirePath + "/" + sprite.name + ".prefab";
    
                    string prefabPath = allPath.Substring(allPath.IndexOf("Assets"));
                    PrefabUtility.CreatePrefab(prefabPath, go);
                    GameObject.DestroyImmediate(go);
                }
            }    
        }
    }
  • 相关阅读:
    加解密相关
    Office常见问题及解决方法
    文件校验和(checksum或Hash)计算工具
    linux install mpi4py
    [zz] Install VSFTP
    Bring up a website by wordpress
    How to Get Rid of /wordpress/ From your WordPress Site URL
    Change http port in bitnami stack
    mongodb gdal 矢量数据格式驱动
    配置PostgreSQL Streaming Replication集群
  • 原文地址:https://www.cnblogs.com/didiaodexi/p/4449590.html
Copyright © 2011-2022 走看看