Example #1
0
 /// <summary>
 /// 内部接口 创建显示对象设置自适应
 /// </summary>
 public void Create()
 {
     _mainCom = UIPackage.CreateObject(_pkgPath, _mainPath);//创建窗体
     //设置屏幕自适应
     _mainCom.SetSize(GRoot.inst.width, GRoot.inst.height);
     _mainCom.AddRelation(GRoot.inst, RelationType.Size);
     GRoot.inst.AddChild(_mainCom);
     OnInit();
 }
Example #2
0
    /// <summary>
    /// 首次进入这个界面
    /// </summary>
    protected override void OnInit()
    {
        base.OnInit();
        GObject windObj = UIPackage.CreateObject(this.PackName, this.ResName);

        if (windObj == null)
        {
            throw new System.Exception("不存在包名:" + this.PackName + "/ResName=" + ResName);
        }
        windObj.SetSize(GRoot.inst.width, GRoot.inst.height);
        this.contentPane = windObj.asCom;
        this.container.cachedTransform.position   = Vector3.zero;
        this.container.cachedTransform.localScale = Vector3.one;

        if (this.contentPane == null)
        {
            Debug.LogError("创建物体失败");
        }


        var obj      = this.contentPane.GetChild(BlackBgName);
        var closeBtn = this.contentPane.GetChild(mCloseBtnName);

        if (closeBtn != null && closeBtn.asButton != null)
        {
            closeBtn.asButton.onClick.Add(this.OnBtnClose);
        }
        //if (obj != null)
        //{
        //    mBlackBg = obj.asImage;
        //    mBlackBg.pivot = GamUtil.CenterPivot;
        //}

        for (int i = 0; i < this.contentPane.numChildren; i++)
        {
            FairyGUI.GObject gObject = this.contentPane.GetChildAt(i);
            UIObjs[gObject.name] = gObject;
            if (gObject.name.StartsWith(btnNameStartsWith))
            {
                gObject.onClick.Add(a =>
                {
                    OnBtnClick(a.data as FairyGUI.GButton);
                });
            }
        }

        foreach (Controller ctrl in this.contentPane.Controllers)
        {
            this.UICtrls[ctrl.name] = ctrl;
        }
        this.pivot = GamUtil.CenterPivot;
    }
Example #3
0
    /// <summary>
    /// 创建页面对象
    /// </summary>
    public string CreateObject(string _packageName, string _viewName)
    {
        GObject tempMainView = UIPackage.CreateObject(_packageName, _viewName).asCom;

        tempMainView.SetSize(GRoot.inst.width, GRoot.inst.height);
        tempMainView.AddRelation(GRoot.inst, RelationType.Size);
        GRoot.inst.AddChild(tempMainView);

        string tempPackageViewName = GetPackageViewName(_packageName, _viewName);
        string tempObjectId        = GetObjectId(tempPackageViewName, tempMainView);

        if (packageList.ContainsKey(tempPackageViewName))
        {
            packageList[tempPackageViewName].Add(tempObjectId, tempMainView);
        }
        else
        {
            Dictionary <string, GObject> tempList = new Dictionary <string, GObject>();
            tempList.Add(tempObjectId, tempMainView);
            packageList.Add(tempPackageViewName, tempList);
        }

        return(tempPackageViewName + "/" + tempObjectId);
    }
Example #4
0
 public void SetTouchSize(int width, int height)
 {
     touchArea.SetSize(width, height);
 }