public static void registWord()
        {
            // 参数绑定解析
            importParser["name"]   = new NameBinder();
            importParser["img"]    = new ImageBinder();
            importParser["ignore"] = new IgnoreBinder();
            importParser["font"]   = new FontBinder();
            // 脚本组件
            if (PsdSetting.Instance.curGUIType == GUIType.UGUI)
            {
                importParser["button"]     = new ButtonBinder();
                importParser["toggle"]     = new ToggleBinder();
                importParser["slider"]     = new SliderBinder();
                importParser["scrollview"] = new ScrollViewBinder();
                importParser["scrollbar"]  = new ScrollbarBinder();
                importParser["inputfield"] = new InputFieldBinder();
            }
            else if (PsdSetting.Instance.curGUIType == GUIType.NGUI)
            {
                importParser["button"]     = new NButtonBinder();
                importParser["toggle"]     = new NToggleBinder();
                importParser["slider"]     = new NSliderBinder();
                importParser["scrollview"] = new NScrollViewBinder();
                importParser["scrollbar"]  = new NScrollbarBinder();
                importParser["inputfield"] = new NInputFieldBinder();
                importParser["texture"]    = new NTextureBinder();
                importParser["tmpt"]       = new NTempletBinder();
            }

#if NGUI
            NAtlasHelper.LoadAllAtlas(PsdSetting.Instance.AtlasImportFolder);
#endif
            NTempletHelper.LoadAllTemplet(PsdSetting.Instance.TempletImportFolder);
        }
Exemple #2
0
        public override void StartBinding(GameObject gObj, string args, string layerName)
        {
#if NGUI
            GameObject templet = NTempletHelper.GetTempletPrefab(args);
            templet.name = gObj.name;
            templet.transform.SetParent(gObj.transform.parent);
            templet.transform.localPosition = gObj.transform.localPosition;
            templet.transform.localRotation = gObj.transform.localRotation;
            templet.transform.localScale    = gObj.transform.localScale;

            foreach (Transform childTrans in gObj.transform)
            {
                childTrans.SetParent(templet.transform);
            }

            UISprite rootSprite = gObj.GetComponent <UISprite>();
            UIWidget destSprite = templet.GetComponent <UIWidget>();
            if (rootSprite != null && destSprite != null)
            {
                destSprite.depth = rootSprite.depth;
                foreach (Transform childTrans in templet.transform)
                {
                    UIWidget childWidget = childTrans.GetComponent <UIWidget>();
                    if (childWidget == null)
                    {
                        return;
                    }
                    childWidget.depth += rootSprite.depth;
                }
                destSprite.width  = rootSprite.width;
                destSprite.height = rootSprite.height;
            }
#endif
        }