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

        UIPackage.AddPackage("UI/Emoji");

        UIConfig.verticalScrollBar = UIPackage.GetItemURL("Emoji", "ScrollBar_VT");
        UIConfig.defaultScrollBarDisplay = ScrollBarDisplayType.Auto;

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

        _list = _mainView.GetChild("list").asList;
        _list.RemoveChildrenToPool();
        _input = _mainView.GetChild("input").asTextInput;
        _input.onKeyDown.Add(__inputKeyDown);

        _itemURL1 = UIPackage.GetItemURL("Emoji", "chatLeft");
        _itemURL2 = UIPackage.GetItemURL("Emoji", "chatRight");

        _mainView.GetChild("btnSend").onClick.Add(__clickSendBtn);
        _mainView.GetChild("btnEmoji").onClick.Add(__clickEmojiBtn);

        _emojiSelectUI = UIPackage.CreateObject("Emoji", "EmojiSelectUI").asCom;
        _emojiSelectUI.fairyBatching = true;
        _emojiSelectUI.GetChild("list").asList.onClickItem.Add(__clickEmoji);
    }
    IEnumerator LoadUIPackage()
    {
        string url = Application.streamingAssetsPath.Replace("\\", "/") + "/FairyGUI-Examples/bundleusage.ab";
        if (Application.platform != RuntimePlatform.Android)
            url = "file:///" + url;

        WWW www = new WWW(url);
        yield return www;

        if (string.IsNullOrEmpty(www.error))
        {
            AssetBundle bundle = www.assetBundle;
            if (bundle == null)
            {
                Debug.LogWarning("Run Window->Build FairyGUI example Bundles first.");
                yield return 0;
            }
            UIPackage.AddPackage(bundle);

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

            GRoot.inst.AddChild(_mainView);
            _mainView.GetTransition("t0").Play();
        }
        else
            Debug.LogError(www.error);
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        Stage.inst.onKeyDown.Add(OnKeyDown);

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

        _guideLayer = UIPackage.CreateObject("Guide", "GuideLayer").asCom;
        _guideLayer.SetSize(GRoot.inst.width, GRoot.inst.height);
        _guideLayer.AddRelation(GRoot.inst, RelationType.Size);

        GObject bagBtn = _mainView.GetChild("bagBtn");
        bagBtn.onClick.Add(() =>
        {
            _guideLayer.RemoveFromParent();
        });

        _mainView.GetChild("n2").onClick.Add(() =>
        {
            GRoot.inst.AddChild(_guideLayer); //!!Before using TransformRect(or GlobalToLocal), the object must be added first
            Rect rect = bagBtn.TransformRect(new Rect(0, 0, bagBtn.width, bagBtn.height), _guideLayer);

            GObject window = _guideLayer.GetChild("window");
            window.size = new Vector2((int)rect.size.x, (int)rect.size.y);
            window.TweenMove(new Vector2((int)rect.position.x, (int)rect.position.y), 0.5f);
        });
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/Guide");

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

        _guideLayer = UIPackage.CreateObject("Guide", "GuideLayer").asCom;
        _guideLayer.SetSize(GRoot.inst.width, GRoot.inst.height);
        _guideLayer.AddRelation(GRoot.inst, RelationType.Size);

        GObject bagBtn = _mainView.GetChild("bagBtn");
        bagBtn.onClick.Add(() =>
        {
            _guideLayer.RemoveFromParent();
        });

        _mainView.GetChild("n2").onClick.Add(() => {
            Rect rect = bagBtn.LocalToGlobal(new Rect(0, 0, bagBtn.width, bagBtn.height));
            GRoot.inst.AddChild(_guideLayer); //!!Before using GlobalToLocal, the object must be added first
            rect = bagBtn.TransformRect(new Rect(0, 0, bagBtn.width, bagBtn.height), _guideLayer);

            GObject window = _guideLayer.GetChild("window");
            window.size = new Vector2((int)rect.size.x, (int)rect.size.y);
            window.TweenMove(new Vector2((int)rect.position.x, (int)rect.position.y), 0.5f);
        });
    }
示例#5
0
    void Start()
    {
        Application.targetFrameRate = 60;
        DontDestroyOnLoad(this.gameObject);

        Stage.Instantiate(5);
        Stage.inst.AddChild(new GRoot().displayObject);
        Stage.inst.camera.clearFlags = CameraClearFlags.Depth;
        Stage.inst.onKeyDown.Add(OnKeyDown);

        //setup custom loader classs
        UIObjectFactory.SetLoaderExtension(typeof(MyGLoader));

        GRoot.inst.SetContentScaleFactor(1136, 640);

        UIPackage.AddPackage("BagDemo");

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

        _bagWindow = new BagWindow();

        _mainView.GetChild("bagBtn").onClick.Add(() => { _bagWindow.Show(); });
    }
示例#6
0
    void Start()
    {
        Application.targetFrameRate = 60;
        DontDestroyOnLoad(this.gameObject);

        Stage.Instantiate(5);
        Stage.inst.AddChild(new GRoot().displayObject);
        Stage.inst.camera.clearFlags = CameraClearFlags.Depth;
        Stage.inst.onKeyDown.Add(OnKeyDown);

        GRoot.inst.SetContentScaleFactor(1136, 640);

        UIPackage.AddPackage("UI/JoystickDemo");

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

        _joystick = new JoystickModule(_mainView);
        _joystick.onMove.Add(__joystickMove);
        _joystick.onEnd.Add(__joystickEnd);

        _npc = GameObject.Find("npc").transform;
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/Transition");

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

        _btnGroup = _mainView.GetChild("g0").asGroup;

        _g1 = UIPackage.CreateObject("Transition", "BOSS").asCom;
        _g2 = UIPackage.CreateObject("Transition", "BOSS_SKILL").asCom;
        _g3 = UIPackage.CreateObject("Transition", "TRAP").asCom;
        _g4 = UIPackage.CreateObject("Transition", "GoodHit").asCom;
        _g5 = UIPackage.CreateObject("Transition", "PowerUp").asCom;
        _g5.GetTransition("t0").SetHook("play_num_now", __playNum);

        _mainView.GetChild("btn0").onClick.Add(() => { __play(_g1); });
        _mainView.GetChild("btn1").onClick.Add(() => { __play(_g2); });
        _mainView.GetChild("btn2").onClick.Add(() => { __play(_g3); });
        _mainView.GetChild("btn3").onClick.Add(__play4);
        _mainView.GetChild("btn4").onClick.Add(__play5);
    }
示例#8
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>();
    }
示例#9
0
    void Start()
    {
        Application.targetFrameRate = 60;
        DontDestroyOnLoad(this.gameObject);

        Stage.Instantiate(5);
        Stage.inst.AddChild(new GRoot().displayObject);
        Stage.inst.camera.clearFlags = CameraClearFlags.Depth;
        Stage.inst.onKeyDown.Add(OnKeyDown);

        GRoot.inst.SetContentScaleFactor(1136, 640);

        UIPackage.AddPackage("UI/CustomMaterialDemo");

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

        _btn0 = _mainView.GetChild("b0").asButton;
        _btn0.icon = "k0";
        _time1 = 5;
        _mat0 = new Material(Shader.Find("Cooldown mask"));
        _mat0.SetFloat("_Progress", 0f);
        _mat0.SetTexture("_MaskTex", (Texture)Resources.Load("CooldownMask"));
        _btn0.GetChild("icon").asLoader.material = _mat0;

        _btn1 = _mainView.GetChild("b1").asButton;
        _btn1.icon = "k1";
        _time2 = 10;
        _mat1 = new Material(Shader.Find("Cooldown mask"));
        _mat1.SetFloat("_Progress", 0f);
        _mat1.SetTexture("_MaskTex", (Texture)Resources.Load("CooldownMask"));
        _btn1.GetChild("icon").asLoader.material = _mat1;
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/HitTest");

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

        cube = GameObject.Find("Cube").transform;
        Stage.inst.onTouchBegin.Add(OnTouchBegin);
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/RenderTexture");

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

        _testWin = new Window3();

        _mainView.GetChild("n2").onClick.Add(() => { _testWin.Show();  });
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/EmitNumbers");

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

        _npc1 = GameObject.Find("npc1").transform;
        _npc2 = GameObject.Find("npc2").transform;

        StartCoroutine(RunTest());
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/Model");

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

        Object prefab = Resources.Load("Role/npc");
        GameObject go = (GameObject)Object.Instantiate(prefab);
        go.transform.localPosition = new Vector3(61, -89, 1000); //set z to far from UICamera is important!
        go.transform.localScale = new Vector3(180, 180, 180);
        go.transform.localEulerAngles = new Vector3(0, 100, 0);
        _mainView.GetChild("holder").asGraph.SetNativeObject(new GoWrapper(go));
    }
示例#14
0
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        //Register custom loader class
        UIObjectFactory.SetLoaderExtension(typeof(MyGLoader));

        UIPackage.AddPackage("UI/Bag");

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

        _bagWindow = new BagWindow();

        _mainView.GetChild("bagBtn").onClick.Add(() => { _bagWindow.Show(); });
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/Joystick");

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

        _text = _mainView.GetChild("n9").asTextField;

        _joystick = new JoystickModule(_mainView);
        _joystick.onMove.Add(__joystickMove);
        _joystick.onEnd.Add(__joystickEnd);
    }
    public void Init()
    {
        _cutSceneView = UIPackage.CreateObject("CutScene", "CutScene").asCom;
        _cutSceneView.SetSize(GRoot.inst.width, GRoot.inst.height);
        _cutSceneView.AddRelation(GRoot.inst, RelationType.Size);

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

        _mainView.GetChild("n0").onClick.Add(() =>
        {
            LoadLevel("scene1");
        });

        _mainView.GetChild("n1").onClick.Add(() =>
        {
            LoadLevel("scene2");
        });
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/Particles");

        UIObjectFactory.SetPackageItemExtension(UIPackage.GetItemURL("Particles", "CoolComponent"), typeof(CoolComponent));

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

        Object prefab = Resources.Load("Flame");
        GameObject go = (GameObject)Object.Instantiate(prefab);
        _mainView.GetChild("holder").asGraph.SetNativeObject(new GoWrapper(go));

        _mainView.GetChild("c0").draggable = true;
        _mainView.GetChild("c1").draggable = true;
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/Extension");
        UIObjectFactory.SetPackageItemExtension(UIPackage.GetItemURL("Extension", "mailItem"), typeof(MailItem));

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

        _list = _mainView.GetChild("mailList").asList;
        for (int i = 0; i < 10; i++)
        {
            MailItem item = (MailItem)_list.AddItemFromPool();
            item.setFetched(i % 3 == 0);
            item.setRead(i % 2 == 0);
            item.setTime("5 Nov 2015 16:24:33");
            item.title = "Mail title here";
        }

        _list.EnsureBoundsCorrect();
        float delay = 0f;
        for (int i = 0; i < 10; i++)
        {
            MailItem item = (MailItem)_list.GetChildAt(i);
            if (_list.IsChildInView(item))
            {
                item.PlayEffect(delay);
                delay += 0.2f;
            }
            else
                break;
        }
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/LoopList");

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

        _list = _mainView.GetChild("list").asList;
        _list.SetVirtualAndLoop();

        _list.itemRenderer = RenderListItem;
        _list.numItems = 5;
        _list.scrollPane.onScroll.Add(DoSpecialEffect);

        DoSpecialEffect();
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/Cooldown");

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

        _btn0 = _mainView.GetChild("b0").asButton;
        _btn0.icon = "Cooldown/k0";
        _time1 = 5;
        _mask0 = _btn0.GetChild("mask").asImage;

        _btn1 = _mainView.GetChild("b1").asButton;
        _btn1.icon = "Cooldown/k1";
        _time2 = 10;
        _mask1 = _btn1.GetChild("mask").asImage;
    }
示例#21
0
    void Start()
    {
        Application.targetFrameRate = 60;
        DontDestroyOnLoad(this.gameObject);

        Stage.Instantiate(5);
        Stage.inst.AddChild(new GRoot().displayObject);
        Stage.inst.camera.clearFlags = CameraClearFlags.Depth;
        Stage.inst.onKeyDown.Add(OnKeyDown);

        GRoot.inst.SetContentScaleFactor(1136, 640);

        UIPackage.AddPackage("UI/RenderTextureDemo");

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

        _testWindow = new TestWindow();

        _mainView.GetChild("bagBtn").onClick.Add(() => { _testWindow.Show(); });
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/ModalWaiting");
        UIConfig.globalModalWaiting = UIPackage.GetItemURL("ModalWaiting", "GlobalModalWaiting");
        UIConfig.windowModalWaiting = UIPackage.GetItemURL("ModalWaiting", "WindowModalWaiting");

        UIObjectFactory.SetPackageItemExtension(UIPackage.GetItemURL("ModalWaiting", "GlobalModalWaiting"), typeof(GlobalWaiting));

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

        _testWin = new Window4();

        _mainView.GetChild("n0").onClick.Add(() => { _testWin.Show(); });

        StartCoroutine(WaitSomeTime());
    }
示例#23
0
    void Start()
    {
        Application.targetFrameRate = 60;
        DontDestroyOnLoad(this.gameObject);

        Stage.Instantiate(5);
        Stage.inst.AddChild(new GRoot().displayObject);
        Stage.inst.camera.clearFlags = CameraClearFlags.Depth;
        Stage.inst.onKeyDown.Add(OnKeyDown);

        GRoot.inst.SetContentScaleFactor(1136, 640);

        UIPackage.AddPackage("UI/EmojiDemo");

        UIConfig.verticalScrollBar = UIPackage.GetItemURL("Demo", "ScrollBar_VT");
        UIConfig.defaultScrollBarDisplay = ScrollBarDisplayType.Auto;

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

        _list = _mainView.GetChild("list").asList;
        _list.RemoveChildrenToPool();
        _input = _mainView.GetChild("input").asTextInput;
        _input.onKeyDown.Add(__inputKeyDown);

        _itemURL1 = UIPackage.GetItemURL("Demo", "chatLeft");
        _itemURL2 = UIPackage.GetItemURL("Demo", "chatRight");

        _mainView.GetChild("btnSend").onClick.Add(__clickSendBtn);
        _mainView.GetChild("btnEmoji").onClick.Add(__clickEmojiBtn);

        _emojiSelectUI = UIPackage.CreateObject("Demo", "EmojiSelectUI").asCom;
        _emojiSelectUI.GetChild("list").asList.onClickItem.Add(__clickEmoji);
    }
    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);
        }
    }
示例#25
0
        void HandleScreenSizeChanged()
        {
            if (!Application.isPlaying)
            {
                DisplayOptions.SetEditModeHideFlags();
            }

            screenSizeVer = StageCamera.screenSizeVer;

            if (this.container != null)
            {
                if (this.container.renderMode != RenderMode.WorldSpace)
                {
                    this.container.scale = new Vector2(StageCamera.UnitsPerPixel * UIContentScaler.scaleFactor, StageCamera.UnitsPerPixel * UIContentScaler.scaleFactor);
                }
            }

            int width  = Mathf.CeilToInt(Screen.width / UIContentScaler.scaleFactor);
            int height = Mathf.CeilToInt(Screen.height / UIContentScaler.scaleFactor);

            if (_ui != null)
            {
                switch (fitScreen)
                {
                case FitScreen.FitSize:
                    _ui.SetSize(width, height);
                    _ui.SetXY(0, 0, true);
                    break;

                case FitScreen.FitWidthAndSetMiddle:
                    _ui.SetSize(width, _ui.sourceHeight);
                    _ui.SetXY(0, (int)((height - _ui.sourceHeight) / 2), true);
                    break;

                case FitScreen.FitHeightAndSetCenter:
                    _ui.SetSize(_ui.sourceWidth, height);
                    _ui.SetXY((int)((width - _ui.sourceWidth) / 2), 0, true);
                    break;
                }

                UpdateHitArea();
            }
            else
            {
                switch (fitScreen)
                {
                case FitScreen.FitSize:
                    uiBounds.position = new Vector2(0, 0);
                    uiBounds.size     = new Vector2(width, height);
                    break;

                case FitScreen.FitWidthAndSetMiddle:
                    uiBounds.position = new Vector2(0, (int)((height - cachedUISize.y) / 2));
                    uiBounds.size     = new Vector2(width, cachedUISize.y);
                    break;

                case FitScreen.FitHeightAndSetCenter:
                    uiBounds.position = new Vector2((int)((width - cachedUISize.x) / 2), 0);
                    uiBounds.size     = new Vector2(cachedUISize.x, height);
                    break;
                }
            }
        }
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/Gesture");

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

        GObject holder = _mainView.GetChild("holder");

        _ball = GameObject.Find("Globe").transform;

        SwipeGesture gesture1 = new SwipeGesture(holder);
        gesture1.onMove.Add(OnSwipeMove);
        gesture1.onEnd.Add(OnSwipeEnd);

        LongPressGesture gesture2 = new LongPressGesture(holder);
        gesture2.once = false;
        gesture2.onAction.Add(OnHold);

        PinchGesture gesture3 = new PinchGesture(holder);
        gesture3.onAction.Add(OnPinch);

        RotationGesture gesture4 = new RotationGesture(holder);
        gesture4.onAction.Add(OnRotate);
    }
示例#27
0
        void HandleScreenSizeChanged()
        {
            if (!Application.isPlaying)
            {
                DisplayObject.hideFlags = HideFlags.DontSaveInEditor;
            }

            screenSizeVer = StageCamera.screenSizeVer;

            int width  = Screen.width;
            int height = Screen.height;

            if (this.container != null)
            {
                Camera cam = container.GetRenderCamera();
                if (cam.targetDisplay != 0 && cam.targetDisplay < Display.displays.Length)
                {
                    width  = Display.displays[cam.targetDisplay].renderingWidth;
                    height = Display.displays[cam.targetDisplay].renderingHeight;
                }

                if (this.container.renderMode != RenderMode.WorldSpace)
                {
                    StageCamera sc = cam.GetComponent <StageCamera>();
                    if (sc == null)
                    {
                        sc = StageCamera.main.GetComponent <StageCamera>();
                    }
                    this.container.scale = new Vector2(sc.unitsPerPixel * UIContentScaler.scaleFactor, sc.unitsPerPixel * UIContentScaler.scaleFactor);
                }
            }

            width  = Mathf.CeilToInt(width / UIContentScaler.scaleFactor);
            height = Mathf.CeilToInt(height / UIContentScaler.scaleFactor);
            if (_ui != null)
            {
                switch (fitScreen)
                {
                case FitScreen.FitSize:
                    _ui.SetSize(width, height);
                    _ui.SetXY(0, 0, true);
                    break;

                case FitScreen.FitWidthAndSetMiddle:
                    _ui.SetSize(width, _ui.sourceHeight);
                    _ui.SetXY(0, (int)((height - _ui.sourceHeight) / 2), true);
                    break;

                case FitScreen.FitHeightAndSetCenter:
                    _ui.SetSize(_ui.sourceWidth, height);
                    _ui.SetXY((int)((width - _ui.sourceWidth) / 2), 0, true);
                    break;
                }

                UpdateHitArea();
            }
            else
            {
                switch (fitScreen)
                {
                case FitScreen.FitSize:
                    uiBounds.position = new Vector2(0, 0);
                    uiBounds.size     = new Vector2(width, height);
                    break;

                case FitScreen.FitWidthAndSetMiddle:
                    uiBounds.position = new Vector2(0, (int)((height - cachedUISize.y) / 2));
                    uiBounds.size     = new Vector2(width, cachedUISize.y);
                    break;

                case FitScreen.FitHeightAndSetCenter:
                    uiBounds.position = new Vector2((int)((width - cachedUISize.x) / 2), 0);
                    uiBounds.size     = new Vector2(cachedUISize.x, height);
                    break;
                }
            }
        }