Example #1
0
    void Start()
    {
        if (!string.IsNullOrEmpty(MultiLanguage.FirstWindowTitlebar))
        {
            titlebar.text = MultiLanguage.FirstWindowTitlebar;
        }

        scroll_rect_ = GenericUtils.FindChildByName <ScrollRect>(gameObject, "ScrollRect");
        item_        = GenericUtils.FindChildByName(gameObject, "Item", true);
        setting_     = GenericUtils.FindChildByName(gameObject, "optionbtn", true);
        GenericUtils.SetListenerOnClick(setting_, OnOptionClick);

        GenericUtils.FindChildByName <Text>(gameObject, "version")
        .text = Application.version + " ";

        GetList(Application.persistentDataPath);
        setting_.SetActive(true);

#if UNITY_EDITOR
        var main_entry = GameObject.FindObjectOfType <MainEntry>();
        if (!string.IsNullOrEmpty(main_entry.era_path))
        {
            GetList(main_entry.era_path);
        }
#endif
#if UNITY_ANDROID && !UNITY_EDITOR
        GetList("storage/emulated/0/emuera");
        GetList("storage/emulated/1/emuera");
        GetList("storage/emulated/2/emuera");

        GetList("storage/sdcard0/emuera");
        GetList("storage/sdcard1/emuera");
        GetList("storage/sdcard2/emuera");
#endif
    }
Example #2
0
    void AddItem(string folder, string workspace)
    {
        var rrt  = item_.transform as UnityEngine.RectTransform;
        var obj  = GameObject.Instantiate(item_);
        var text = GenericUtils.FindChildByName <UnityEngine.UI.Text>(obj, "name");

        text.text = folder;
        text      = GenericUtils.FindChildByName <UnityEngine.UI.Text>(obj, "path");
        text.text = workspace + "/" + folder;

        GenericUtils.SetListenerOnClick(obj, () =>
        {
            scroll_rect_ = null;
            item_        = null;
            GameObject.Destroy(gameObject);
            //Start Game
            GenericUtils.StartCoroutine(Run(workspace, folder));
        });

        var rt      = obj.transform as UnityEngine.RectTransform;
        var content = scroll_rect_.content;

        rt.SetParent(content);
        rt.localScale    = Vector3.one;
        rt.anchorMax     = rrt.anchorMax;
        rt.anchorMin     = rrt.anchorMin;
        rt.offsetMax     = rrt.offsetMax;
        rt.offsetMin     = rrt.offsetMin;
        rt.sizeDelta     = rrt.sizeDelta;
        rt.localPosition = new Vector2(0, -rt.sizeDelta.y * itemcount_);
        itemcount_      += 1;

        var ih = rt.sizeDelta.y * itemcount_;

        if (ih > content.sizeDelta.y)
        {
            content.sizeDelta = new Vector2(content.sizeDelta.x, ih);
        }
        obj.SetActive(true);
    }