public virtual object getNewInstance()
        {
            object result = null;

            if (_data is UnityEngine.Object)
            {
                if (_data is GameObject)
                {
                    if (isShaderFinded == false)
                    {
                        isShaderFinded = true;
                        RenderUtils.ShaderFind((GameObject)_data);
                    }
                }

                try
                {
                    result = GameObject.Instantiate(_data as UnityEngine.Object) as object;
                }
                catch (Exception e)
                {
                    DebugX.LogError("getNewInstance Error:{0}", e.Message);
                }
            }
            return(result);
        }
Beispiel #2
0
        public override object getNewInstance()
        {
            object result = null;

            _asset = (UnityEngine.Object)getMainAsset();
            if (_asset == null)
            {
                return(result);
            }

            try
            {
                if (isShaderFinded == false)
                {
                    isShaderFinded = true;
                    RenderUtils.ShaderFind((GameObject)_asset);
                }
                result = GameObject.Instantiate(_asset) as object;
            }
            catch (Exception e)
            {
                DebugX.LogError("getNewInstance Error:{0}", e.Message);
            }

            return(result);
        }
Beispiel #3
0
 private void add(float delayTime, Action handler)
 {
     ___addHandle(handler, Time.time + delayTime, true);
     if (len > 0)
     {
         TickManager.Add(render);
     }
     else if (firstNode != null)
     {
         TickManager.Add(render);
         DebugX.LogError("callLater 有bug:" + len);
     }
 }
Beispiel #4
0
        public object getNewInstance()
        {
            object result = null;

            try
            {
                result = GameObject.Instantiate(_data as UnityEngine.Object) as object;
            }
            catch (Exception e)
            {
                DebugX.LogError("getNewInstance Error:{0}", e.Message);
            }

            return(result);
        }
Beispiel #5
0
        protected bool _remove(ActionNode <T> t, Action value)
        {
            if (t == null)
            {
                DebugX.LogError("queueAction error nil");
            }

            ActionNode <T> pre  = t.pre;
            ActionNode <T> next = t.next;

            if (pre != null)
            {
                pre.next = next;
            }
            else
            {
                firstNode = next;
            }

            if (next != null)
            {
                next.pre = pre;
            }
            else
            {
                lastNode = pre;
            }
            t.active = NodeActiveState.ToDoDelete;

            maping.Remove(value);

            if (NodePool.Count < MAX)
            {
                t.action = null;
                t.pre    = t.next = null;
                NodePool.Push(t);
            }
            len--;


            if (len < 0)
            {
                DebugX.LogError("QueueAction lenError:" + len);
            }

            return(true);
        }
        private void loadHandle(EventX e)
        {
            RFLoader target = (RFLoader)e.target;

            runingList.Remove(target);
            running--;

            Log("CorEnd: {0} {1},{2}", running, e.type, target._url);

            if (running < 0)
            {
                DebugX.LogError("coreLoaderQueue error {0} {1},{2}", running, e.type, target._url);
            }

            target.removeEventListener(EventX.COMPLETE, loadHandle);
            target.removeEventListener(EventX.FAILED, loadHandle);
            target.removeEventListener(EventX.DISPOSE, loadHandle);
        }
Beispiel #7
0
        private void itemComplete(EventX e)
        {
            AssetResource resource = e.target as AssetResource;

            AssetsManager.bindEventHandle(resource, itemComplete, false);
            resource.removeEventListener(EventX.PROGRESS, itemProgress);
            resource.removeEventListener(EventX.DISPOSE, itemComplete);

            runningList.Remove(resource);
            running--;
            Log("QuEnd: {0} {1},{2},{3}", running, e.type, resource.url, queue.Count);

            if (running < 0)
            {
                DebugX.LogError("queueLoader error runnig=" + running);
            }

            if (e.type != EventX.COMPLETE)
            {
                faildCount++;
                if (maxFailCount > 0 && faildCount > maxFailCount)
                {
                    this.simpleDispatch(EventX.FAILED, e);
                }
                DebugX.LogWarning("QuItemFailed:" + resource.url + ":" + e.type + " faildCount:" + faildCount + "/" + maxFailCount);
            }

            preProgress = 0.0f;
            loaded      = total - (queue.Count + running);
            //DebugX.Log("kk:" + (loaded) / (float)total);
            this.simpleDispatch(EventX.PROGRESS, loaded / (float)total);

            Action <EventX> action = null;

            string key = resource.url.ToLower();

            if (resultActions.TryGetValue(key, out action))
            {
                action(e);
            }

            _doNext();
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="url"></param>
        /// <param name="uri"></param>
        /// <param name="type"></param>
        /// <param name="resultHandle">同url只返回一次回调</param>
        /// <returns></returns>
        public AssetResource add(string url, LoaderXDataType type, Action <EventX> resultHandle = null)
        {
            if (isStart)
            {
                DebugX.LogError("Qu不能在运行时加入:" + url);
            }

            AssetResource resource = null;

            if (string.IsNullOrEmpty(url))
            {
                return(resource);
            }

            string key = url.ToLower();

            if (urlMapping.TryGetValue(key, out resource))
            {
                return(resource);
            }
            resource = AssetsManager.getResource(url, type);
            if (resource == null)
            {
                return(null);
            }

            if (isUseRef)
            {
                resource.retain();
            }

            urlMapping.Add(key, resource);
            queue.Enqueue(resource);
            if (resultHandle != null && resultActions.ContainsKey(key) == false)
            {
                resultActions.Add(key, resultHandle);
            }

            return(resource);
        }
Beispiel #9
0
        private void checkAllComplete()
        {
            if (_needLoadedDependCount != 0)
            {
                if (_needLoadedDependCount < 0)
                {
                    DebugX.LogError("AssetBundle lenError:" + _needLoadedDependCount + " url:" + url);
                    resourceComplete(EventX.COMPLETE);
                }
                return;
            }

            if (isAutoMainAsset == false)
            {
                resourceComplete(EventX.COMPLETE);
                return;
            }
            if (_data is AssetBundle == false)
            {
                resourceComplete(EventX.COMPLETE);
                return;
            }
            AssetBundle assetBundle = (AssetBundle)_data;

            if (assetBundle.isStreamedSceneAssetBundle)
            {
                resourceComplete(EventX.COMPLETE);
                return;
            }

            string name = GetPrefabNameyDependKey(dependKey);

//            if (RFLoader.USE_ASYNC)
//            {
//                BaseApp.Instance.StartCoroutine(loadAssetAsync(assetBundle,name));
//                return;
//            }
            _asset = assetBundle.LoadAsset(name);
            resourceComplete(EventX.COMPLETE);
        }
Beispiel #10
0
        public void WriteAMF3Object(object value)
        {
            if (!_objectReferences.ContainsKey(value))
            {
                _objectReferences.Add(value, _objectReferences.Count);

                ClassDefinition classDefinition = GetClassDefinition(value);
                if (classDefinition == null)
                {
                    DebugX.LogError("serializing:{0}", value.GetType().FullName);
                    return;
                }
                if (_classDefinitionReferences.ContainsKey(classDefinition))
                {
                    //Existing class-def
                    int handle = (int)_classDefinitionReferences[classDefinition];//handle = classRef 0 1
                    handle = handle << 2;
                    handle = handle | 1;
                    WriteAMF3IntegerData(handle);
                }
                else
                {                //inline class-def
                    //classDefinition = CreateClassDefinition(value);
                    _classDefinitionReferences.Add(classDefinition, _classDefinitionReferences.Count);
                    //handle = memberCount dynamic externalizable 1 1
                    int handle = classDefinition.MemberCount;
                    handle = handle << 1;
                    handle = handle | (classDefinition.IsDynamic ? 1 : 0);
                    handle = handle << 1;
                    handle = handle | (classDefinition.IsExternalizable ? 1 : 0);
                    handle = handle << 2;
                    handle = handle | 3;
                    WriteAMF3IntegerData(handle);
                    WriteAMF3UTF(classDefinition.ClassName);
                    for (int i = 0; i < classDefinition.MemberCount; i++)
                    {
                        string key = classDefinition.Members[i].Name;
                        WriteAMF3UTF(key);
                    }
                }
                //write inline object
                if (classDefinition.IsExternalizable)
                {
                    if (value is IExternalizable)
                    {
                        IExternalizable externalizable = value as IExternalizable;
                        DataOutput      dataOutput     = new DataOutput(this);
                        externalizable.WriteExternal(dataOutput);
                    }
                    else
                    {
                        throw new NotImplementedException(classDefinition.ClassName + " must is IExternalizable");
                    }
                }
                else
                {
                    Type         type  = value.GetType();
                    IObjectProxy proxy = ObjectProxyRegistry.GetObjectProxy(type);

                    for (int i = 0; i < classDefinition.MemberCount; i++)
                    {
                        object memberValue = proxy.GetValue(value, classDefinition.Members[i]);
                        WriteAMF3Data(memberValue);
                    }

                    if (classDefinition.IsDynamic)
                    {
                        IDictionary dictionary = value as IDictionary;
                        foreach (DictionaryEntry entry in dictionary)
                        {
                            WriteAMF3UTF(entry.Key.ToString());
                            WriteAMF3Data(entry.Value);
                        }
                        WriteAMF3UTF(string.Empty);
                    }
                }
            }
            else
            {
                //handle = objectRef 0
                int handle = (int)_objectReferences[value];
                handle = handle << 1;
                WriteAMF3IntegerData(handle);
            }
        }
        public static Dictionary <InjectEventType, Dictionary <string, Action <EventX> > > CollectionEventInterests(
            IEventInterester instance,
            Dictionary <InjectEventType, Dictionary <string, Action <EventX> > > _eventInterests = null)
        {
            Type type = instance.GetType();

            if (_eventInterests == null)
            {
                _eventInterests = new Dictionary <InjectEventType, Dictionary <string, Action <EventX> > >();
            }
            Dictionary <string, Action <EventX> > dic = null;

            MethodInfo[] methods =
                type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            MVCEventAttribute attr;
            Type attributeType = typeof(MVCEventAttribute);
            int  len           = methods.Length;

            for (int i = 0; i < len; i++)
            {
                MethodInfo info  = methods[i];
                object[]   attrs = info.GetCustomAttributes(attributeType, true);
                int        alen  = attrs.Length;
                for (int j = 0; j < alen; j++)
                {
                    attr = attrs[j] as MVCEventAttribute;

                    if (_eventInterests.TryGetValue(attr.injectEventType, out dic) == false)
                    {
                        dic = new Dictionary <string, Action <EventX> >();
                        _eventInterests.Add(attr.injectEventType, dic);
                    }
                    foreach (string eventType in attr.eventList)
                    {
                        if (dic.ContainsKey(eventType) == false)
                        {
                            dic.Add(eventType, (EventX e) =>
                            {
                                try
                                {
                                    info.Invoke(instance, new[] { e });
                                }
                                catch (Exception exception)
                                {
                                    if (exception.InnerException != null)
                                    {
                                        DebugX.LogError(exception.InnerException.ToString());
                                    }
                                    //DebugX.LogError("class:"+ type.Name+ "MethodInfo:"+ info.Name);
                                }
                            });
                        }
                        else
                        {
                            DebugX.Log("MVCEventAttribute inject:{0} type:{1} not exist event:{2}", type.FullName,
                                       attr.injectEventType, eventType);
                        }
                    }
                }
            }
            return(_eventInterests);
        }