示例#1
0
        public static void Init(IResLoad resLoad = null)
        {
            if (appdomain != null)
            {
                return;
            }

#if UNITY_EDITOR
            DllInitByEditor.Release();
#endif
            if (resLoad == null)
            {
#if UNITY_EDITOR
                ResLoad.Set(new EditorResLoad());
#endif
            }
            else
            {
                ResLoad.Set(resLoad);
            }

            InitHotModule();

#if HOT_DEBUG
            if (UnityEngine.Application.isPlaying)
            {
                System.Type debugger_type;
                if (IL.Help.TryGetTypeByFullName("hot.Debugger", out debugger_type))
                {
                    var    debugger = new RefType(true, debugger_type);
                    object port     = debugger.TryGetField("port");
                    if (port != null)
                    {
                        var ds = appdomain.DebugService;
                        ds.StartDebugService((int)port);
                        object vsWaitTimeoutTime = debugger.TryGetField("vsWaitTimeoutTime");
                        if (vsWaitTimeoutTime != null)
                        {
                            int wt = (int)vsWaitTimeoutTime;
                            if (wt > 0)
                            {
                                L.Log("vsWait begin!");
                                int count = 0;
                                while (!ds.IsDebuggerAttached)
                                {
                                    System.Threading.Thread.Sleep(1000);
                                    ++count;
                                    if (count >= wt)
                                    {
                                        L.Log("vsWait timeout!");
                                        break;
                                    }
                                }
                                L.Log("vsWait end!");
                            }
                        }
                    }
                }
            }
#endif
            refType = new RefType("hot.hotApp");
            refType.TryInvokeMethod("Init");

            AllTypes = new List <IType>();
            foreach (var ator in appdomain.LoadedTypes)
            {
                AllTypes.Add(ator.Value);
            }

            AutoReplace(AllTypes);
            InitByProperty(typeof(AutoInitAndRelease), "Init", AllTypes);
        }
示例#2
0
 public void OnTypeChange(string newTypeName)
 {
     typeName = newTypeName;
     instance = null;
     refType_ = null;
 }