• 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);
                }
            }    
        }
    }
  • 相关阅读:
    AWS Redshift 采坑记
    EF Core 小工具
    Setup .net core EF
    Bat 使用MSBuild 制作发布包 (更新20180713)
    Https web Api 拉取数据踩坑记录
    C# 后台程序 通过批处理进行监控
    C#计算日期步进
    IIS 预热 (8.0及8.0以上版本)
    MSBuild 执行文档,关于使用命令行编译
    基于Bamboo的CI配置汇总(.Net Web及Api)
  • 原文地址:https://www.cnblogs.com/didiaodexi/p/4449590.html
Copyright © 2020-2023  润新知