GetController() public method

Returns a controller object with a certain name.
public GetController ( string name ) : FairyGUI.Controller
name string Name
return FairyGUI.Controller
示例#1
0
    public MainPanel()
    {
        _view = UIPackage.CreateObject("Demo", "Demo").asCom;
        _view.fairyBatching = true;//优化drawcall,可以切换这条语句看效果
        _view.SetSize(GRoot.inst.width, GRoot.inst.height);
        _view.AddRelation(GRoot.inst, RelationType.Size);
        GRoot.inst.AddChild(_view);

        _backBtn = _view.GetChild("btn_Back");
        _backBtn.visible = false;
        _backBtn.onClick.Add(onClickBack);

        _demoContainer = _view.GetChild("container").asCom;
        _cc = _view.GetController("c1");

        int cnt = _view.numChildren;
        for (int i = 0; i < cnt; i++)
        {
            GObject obj = _view.GetChildAt(i);
            if (obj.group != null && obj.group.name == "btns")
                obj.onClick.Add(runDemo);
        }

        _demoObjects = new Dictionary<string, GComponent>();
    }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        void CreateCell(GTreeNode node)
        {
            GComponent child = itemPool.GetObject(string.IsNullOrEmpty(node._resURL) ? this.defaultItem : node._resURL) as GComponent;

            if (child == null)
            {
                throw new Exception("FairyGUI: cannot create tree node object.");
            }
            child.displayObject.home = this.displayObject.cachedTransform;
            child._treeNode          = node;
            node._cell = child;

            GObject indentObj = node.cell.GetChild("indent");

            if (indentObj != null)
            {
                indentObj.width = (node.level - 1) * indent;
            }

            Controller cc;

            cc = child.GetController("expanded");
            if (cc != null)
            {
                cc.onChanged.Add(__expandedStateChanged);
                cc.selectedIndex = node.expanded ? 1 : 0;
            }

            cc = child.GetController("leaf");
            if (cc != null)
            {
                cc.selectedIndex = node.isFolder ? 0 : 1;
            }

            if (node.isFolder)
            {
                child.onTouchBegin.Add(__cellTouchBegin);
            }

            if (treeNodeRender != null)
            {
                treeNodeRender(node, node._cell);
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        void CreateCell(GTreeNode node)
        {
            GComponent child = itemPool.GetObject(node._resURL) as GComponent;

            if (child == null)
            {
                throw new Exception("FairyGUI: cannot create tree node object.");
            }
            child._treeNode = node;
            node._cell      = child;

            GObject indentObj = node.cell.GetChild("indent");

            if (indentObj != null)
            {
                indentObj.width = (node.level - 1) * indent;
            }

            Controller cc;

            cc = child.GetController("expanded");
            if (cc != null)
            {
                cc.onChanged.Add(__expandedStateChanged);
                cc.selectedIndex = node.expanded ? 1 : 0;
            }

            cc = child.GetController("leaf");
            if (cc != null)
            {
                cc.selectedIndex = node.isFolder ? 0 : 1;
            }

            if (treeNodeRender != null)
            {
                treeNodeRender(node, node._cell);
            }
        }
示例#4
0
 static public int GetController(IntPtr l)
 {
     try {
         FairyGUI.GComponent self = (FairyGUI.GComponent)checkSelf(l);
         System.String       a1;
         checkType(l, 2, out a1);
         var ret = self.GetController(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static int GetController(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.GComponent obj = (FairyGUI.GComponent)ToLua.CheckObject(L, 1, typeof(FairyGUI.GComponent));
         string arg0             = ToLua.CheckString(L, 2);
         FairyGUI.Controller o   = obj.GetController(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#6
0
    void Start()
    {
        Application.targetFrameRate = 60;
        Stage.inst.onKeyDown.Add(OnKeyDown);

        _mainView = this.GetComponent<UIPanel>().ui;

        _backBtn = _mainView.GetChild("btn_Back");
        _backBtn.visible = false;
        _backBtn.onClick.Add(onClickBack);

        _demoContainer = _mainView.GetChild("container").asCom;
        _viewController = _mainView.GetController("c1");

        _demoObjects = new Dictionary<string, GComponent>();

        int cnt = _mainView.numChildren;
        for (int i = 0; i < cnt; i++)
        {
            GObject obj = _mainView.GetChildAt(i);
            if (obj.group != null && obj.group.name == "btns")
                obj.onClick.Add(runDemo);
        }
    }
    void Start()
    {
        #if UNITY_WEBPLAYER || UNITY_WEBGL || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR
        CopyPastePatch.Apply();
        #endif

        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/Basics");

        #if UNITY_5
        //Use the font names directly
        UIConfig.defaultFont = "Droid Sans,Droid Sans Fallback,Microsoft YaHei";
        #else
        //Need to put a ttf file into Resources folder. Here is the file name of the ttf file.
        UIConfig.defaultFont = "afont";
        #endif

        UIConfig.verticalScrollBar = UIPackage.GetItemURL("Basics", "ScrollBar_VT");
        UIConfig.horizontalScrollBar = UIPackage.GetItemURL("Basics", "ScrollBar_HZ");
        UIConfig.popupMenu = UIPackage.GetItemURL("Basics", "PopupMenu");
        UIConfig.buttonSound = (AudioClip)UIPackage.GetItemAsset("Basics", "click");

        _mainView = UIPackage.CreateObject("Basics", "Main").asCom;
        _mainView.fairyBatching = true;
        _mainView.SetSize(GRoot.inst.width, GRoot.inst.height);
        _mainView.AddRelation(GRoot.inst, RelationType.Size);
        GRoot.inst.AddChild(_mainView);

        _backBtn = _mainView.GetChild("btn_Back");
        _backBtn.visible = false;
        _backBtn.onClick.Add(onClickBack);

        _demoContainer = _mainView.GetChild("container").asCom;
        _viewController = _mainView.GetController("c1");

        _demoObjects = new Dictionary<string, GComponent>();

        int cnt = _mainView.numChildren;
        for (int i = 0; i < cnt; i++)
        {
            GObject obj = _mainView.GetChildAt(i);
            if (obj.group != null && obj.group.name == "btns")
                obj.onClick.Add(runDemo);
        }
    }