帮酷LOGO
  • 显示原文与译文双语对照的内容
文章标签:  framework  BASE  
a simple UI framework based on UGUI

  • 源代码名称:Unity-UI-Framework
  • 源代码网址:http://www.github.com/MrNerverDie/Unity-UI-Framework
  • Unity-UI-Framework源代码文档
  • Unity-UI-Framework源代码下载
  • Git URL:
    git://www.github.com/MrNerverDie/Unity-UI-Framework.git
  • Git Clone代码到本地:
    git clone http://www.github.com/MrNerverDie/Unity-UI-Framework
  • Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/MrNerverDie/Unity-UI-Framework
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
  • #Unity-UI-Framework的设计与实现

    @(归档)[Unity3D, UGUI ]

    [TOC ]

    ###如何使用

    MainMenu

    ###基本概念:View,Context和UI的定义

    public class UIType {
     public string Path { get; private set; }
     public string Name { get; private set; }
     public UIType(string path)
     {
     Path = path;
     Name = path.Substring(path.LastIndexOf('/') + 1);
     }
     public override string ToString()
     {
     return string.Format("path : {0} name : {1}", Path, Name);
     }
    }

     public class OptionMenuContext :BaseContext
     {
     public OptionMenuContext() : base(UIType.OptionMenu){}
     }
     public class OptionMenuView : AnimateView
     {
     public override void OnEnter(BaseContext context)
     public override void OnExit(BaseContext context)
     public override void OnPause(BaseContext context)
     public override void OnResume(BaseContext context)
     }

    ###View的创建和销毁

    public static readonly UIType MainMenu = new UIType("View/MainMenuView");
    public static readonly UIType OptionMenu = new UIType("View/OptionMenuView");
    public static readonly UIType NextMenu = new UIType("View/NextMenuView");
    public static readonly UIType HighScore = new UIType("View/HighScoreView");

    ###View的跳转

    ContextManger.Instance.Push(nextContext)

    ###View的动画

    ViewAnimator

    ###本地化

    ###分辨率适配

    UGUI中的分辨率适配是通过CanvasScaler来实现的,如下图:CanvasScaler

    ###提升滑动列表的性能

    [RequireComponent(typeof(ScrollRect))]
    public class GridScroller : MonoBehaviour {
    //public UI elements//
     [SerializeField]
     private Transform _itemPrefab;
     [SerializeField]
     private GridLayoutGroup _grid;
    //public fields//
     [SerializeField]
     private Movement _moveType = Movement.Horizontal;
     public delegate void OnChange(Transform trans, int index);
     public void Init(OnChange onChange, int itemCount, Vector2? normalizedPosition = null)
     {
     Clear();
     InitScroller();
     InitGrid();
     InitChildren(onChange, itemCount);
     InitTransform(normalizedPosition);
     }

    ###对UI进行修饰



    文章标签:  BASE  framework  

    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语