Esempio n. 1
0
    private void Start()
    {
#if UNITY_ANDROID
        MonoInstancePool.getInstance <SDK_Orientation>(true).ShowBar();
#endif
        Screen.fullScreen = true;
        MonoInstancePool.getInstance <AntiScriptSplit>(true);
        MonoInstancePool.getInstance <SDK_WeChat>(true);

        trUIAlert   = UStaticFuncs.FindChildComponent <Transform>(transform, "UIAlert");
        fprocessing = 0.1f;
#if UNITY_IOS
        MonoInstancePool.getInstance <SDK_AppleInApp>(true);
#endif

        gameObject.AddComponent <UConsoleDebug>();
#if !UNITY_WEBGL
        var fa = "fa" + Utils_Plugins.Util_GetBundleVersion();
        if (!PlayerPrefs.HasKey(fa))
        {
            AOutput.Log($"start copy files {fa}");
            MonoInstancePool.getInstance <UCopyFilesFromStreamingAssets>().OnCopy("versions.txt", UStaticFuncs.ConfigSaveDir, () =>
            {
                InitRemoteConfig();
                PlayerPrefs.SetInt("fa" + Utils_Plugins.Util_GetBundleVersion(), 1);
            });
        }
        else
        {
#endif
        InitRemoteConfig();
#if !UNITY_WEBGL
    }
#endif
    }
Esempio n. 2
0
    protected void RegistButtonAction(string buttonName, Action clickAction)
    {
        var btn = UStaticFuncs.FindChildComponent <Button>(transform, buttonName);

        if (btn != null)
        {
            btn.onClick.AddListener(() => { clickAction(); });
        }
    }
Esempio n. 3
0
    protected void ShowWidget(string widgetName, bool bShow)
    {
        var w = UStaticFuncs.FindChildComponent <Component>(gameObj.transform, widgetName);

        if (w != null)
        {
            w.gameObject.SetActive(bShow);
        }
    }
Esempio n. 4
0
    public T FindWidgetWithPath <T>(Transform trans, string widgetName) where T : Component
    {
        var t = UStaticFuncs.FindChildComponent <T>(trans, widgetName);

        if (t == null)
        {
            AOutput.Log("FindWidget failed " + widgetName);
        }
        return(t);
    }
Esempio n. 5
0
    protected override void InitComponents()
    {
        Content    = UStaticFuncs.FindChildComponent <Text>(transform, "Content");
        btnConfirm = UStaticFuncs.FindChildComponent <Button>(transform, "btnConfirm");
        btnCancel  = UStaticFuncs.FindChildComponent <Button>(transform, "btnCancel");
        btnConfirm.onClick.AddListener(OnConfirm);
        btnCancel.onClick.AddListener(OnCancel);

        DontDestroyOnLoad(gameObject);
    }
Esempio n. 6
0
    protected void ChangeButtonText(string buttonName, string buttonText)
    {
        var btn = UStaticFuncs.FindChildComponent <Button>(transform, buttonName);

        if (btn == null)
        {
            return;
        }
        var t = btn.GetComponentInChildren <Text>();

        t.text = buttonText;
    }
Esempio n. 7
0
    protected void ShowWidget(Transform tr, string widgetName, bool bShow)
    {
        if (tr == null)
        {
            return;
        }
        var w = UStaticFuncs.FindChildComponent <Component>(tr, widgetName);

        if (w != null)
        {
            w.gameObject.SetActive(bShow);
        }
    }
Esempio n. 8
0
    protected override void InitComponents()
    {
        usernameInput = UStaticFuncs.FindChildComponent <InputField>(transform, "username");
        passwordInput = UStaticFuncs.FindChildComponent <InputField>(transform, "username");
        btnLogin      = UStaticFuncs.FindChildComponent <Button>(transform, "Login");

        btnLogin.onClick.AddListener(
            delegate()
        {
            string username = usernameInput.text;
            string password = passwordInput.text;
            //do login
        });
    }
Esempio n. 9
0
    private void InitProgressSlider()
    {
        UILoading = UAssetBundleDownloader.Instance.OnLoadAsset <Transform>("ui/uiloading");
        Debug.Log($"UILoading {UILoading}");
        if (UILoading == null)
        {
            UILoading = UStaticFuncs.FindChildComponent <Transform>(transform, "UILoading");
        }
        if (UILoading != null)
        {
            UILoading.gameObject.SetActive(true);

            UILoading.GetComponent <Canvas>().sortingOrder = -1;
            SliderProgress = UStaticFuncs.FindChildComponent <Image>(UILoading, "SliderProgress");
            textProgress   = UStaticFuncs.FindChildComponent <Text>(UILoading, "textProgress");
            jindu          = UStaticFuncs.FindChildComponent <Text>(UILoading, "jindu");
            SetJindu("正在初始化,请稍候");
        }
    }
Esempio n. 10
0
    public T FindWidgetWithPath <T>(string widgetNameWithPath) where T : Component
    {
        var parent     = transform;
        var widgetName = widgetNameWithPath;

        widgetNameWithPath = widgetNameWithPath.Replace("\\", "/");
        if (widgetNameWithPath.Contains("/"))
        {
            var alayers = widgetNameWithPath.Split('/');
            widgetName = alayers[alayers.Length - 1];
            for (var i = 0; i < alayers.Length - 1; i++)
            {
                var tr = FindWidgetWithPath <Transform>(parent, alayers[i]);
                if (tr == null)
                {
                    break;
                }
                parent = tr;
            }
        }
        return(UStaticFuncs.FindChildComponent <T>(parent, widgetName));
    }
Esempio n. 11
0
 public T FindWidget <T>(Transform trans, string widgetName) where T : Component
 {
     return(UStaticFuncs.FindChildComponent <T>(trans, widgetName));
 }
Esempio n. 12
0
 public T FindWidget <T>(string widgetName) where T : Component
 {
     return(UStaticFuncs.FindChildComponent <T>(gameObj.transform, widgetName));
 }
Esempio n. 13
0
    public void EmitMessage(string msg)
    {
        Debug.Log("Receive message " + msg);
        var amsg = msg.Split(new char[] { '|' });

        if (amsg[0] == "load")
        {
            var obj = UAssetBundleDownloader.Instance.OnLoadAsset <GameObject>(amsg[2]);
            if (!obj)
            {
                obj = new GameObject(amsg[1]);
            }
            else
            {
                obj = Instantiate(obj);
            }
            ILRuntimeHandler.Instance.OnLoadClass(amsg[1], obj);
        }
        else if (amsg[0] == "loadprefab")
        {
            var obj = UAssetBundleDownloader.Instance.OnLoadAsset <GameObject>(amsg[1]);
            if (obj == null)
            {
                obj = new GameObject(amsg[1]);
            }
            else
            {
                obj = Instantiate(obj);
            }
#if ILRUNTIME
            ILRuntimeHandler.Instance.EmitGameObject(amsg[1], obj, amsg.Length > 2 ? amsg[2] : "");
#endif
        }
        else if (amsg[0] == "unloadall")
        {
            ILRuntimeHandler.Instance.OnUnloadAllClasses();
        }
        else if (amsg[0] == "invoke")
        {
            var ainvoke = amsg[1].Split(new char[] { ':' }, 3);
            if (ainvoke.Length >= 2)
            {
                var objname = ainvoke[0];
                var obj     = MonoInstancePool.OnGetInstance(objname);
                if (obj == null)
                {
                    var aobj = objname.Split('/');
                    if (aobj.Length == 2)
                    {
                        obj = GameObject.Find(aobj[0]);
                        if (obj != null)
                        {
                            var tr = UStaticFuncs.FindChildComponent <Transform>(obj.transform, aobj[1]);
                            if (tr != null)
                            {
                                obj = tr.gameObject;
                            }
                            else
                            {
                                Debug.Log($"cannot find {aobj[1]}");
                            }
                        }
                        else
                        {
                            Debug.Log($"cannot find {aobj[0]}");
                        }
                    }
                    else
                    {
                        obj = GameObject.Find(objname);
                    }
                    if (obj == null)
                    {
                        Debug.Log($"Cannot find obj {objname}");
                        return;
                    }
                }
                if (ainvoke.Length == 2)
                {
                    obj.SendMessage(ainvoke[1]);
                }
                else
                {
                    obj.SendMessage(ainvoke[1], ainvoke[2]);
                }
            }
            else
            {
                Debug.Log($"Invoke 参数数量错误 {msg}");
            }
        }
    }