QFramework (v0.0.9)入门学习(一) UIKit

"Version": "v0.0.9"

因为笔者水平有限,加之也最近才开始接触这个框架,不足之处,请多多指教。

框架github下载地址:https://github.com/liangxiegame/QFramework

框架作者文档:http://qframework.io/

1. 将框架预设体 UIRoot 添加到面板

2.在 Design 里面新建一个 panel ,我这取名为 UIFirstPanel,下级加一个 button(因为我后期需要对这个Button做监听,所以你需要给它加一个 UIMark 组件,任何你需要监听的对象,你都给它加一个这个组件)

3.推荐在Asset目录下建一个这样的文件结构,将刚才的panel拖到文件夹下成为预设体

4.在刚才的 Panel 预设体右键,选择@UIKit,如图所示,成功之后如图二会生成一个UI文件夹目录,并有这两个对应的脚本

5.将这个预设体 Assetbundle名设置为 UIFirstPanel.ab

6.新建一个空对象,挂上一个框架自带的 UIPanelTester.cs (注意这个脚本是你下来的框架就自带的,不用你自己写)

7.点击运行一下Unity ,看一下效果如下:(运行时Design对象会自动隐藏,而Common则会Open出来一个Panel)

 

新建一个Panel push出来的代码如下:

/****************************************************************************
 * Copyright (c) 2018.5 ~ 8 liangxie
 * 
 * http://qframework.io
 * https://github.com/liangxiegame/QFramework
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 ****************************************************************************/

namespace QFramework
{
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    [System.Serializable]
    public class UIPanelTesterInfo
    {
        /// <summary>
        /// 页面的名字
        /// </summary>
        public string PanelName;

        /// <summary>
        /// 层级名字
        /// </summary>
        public UILevel Level;
    }

    public class UIPanelTester : MonoBehaviour
    {
        /// <summary>
        /// 页面的名字
        /// </summary>
        public string PanelName;

        /// <summary>
        /// 层级名字
        /// </summary>
        public UILevel Level;

        [SerializeField] private List<UIPanelTesterInfo> mOtherPanels;

        private void Awake()
        {
            ResMgr.Init();
        }

        private IEnumerator Start()
        {
            yield return new WaitForSeconds(0.2f);

            // 这行代码就是将你创建的 Panel 创建了出来
            UIMgr.OpenPanel(PanelName, Level);

            mOtherPanels.ForEach(panelTesterInfo => { UIMgr.OpenPanel(panelTesterInfo.PanelName, panelTesterInfo.Level); });
        }
    }
}

当初笔者很奇怪,如图一所示,UIManager既然是单例模式,而在这个框架里也是去调的这个单例,,难道就是为了少写一个 .Instance 吗 所以多了一个 UIMgr.cs 的管理器,而后期我们也使用这个脚本去对 UI 进行操作的,最后笔者在框架作者那边得到了回答,大彻大悟,只剩下深深的佩服,如图二所示

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值