Exemple #1
0
        /// <summary>
        /// Reads the new all text. 异步读取。优先从persistentDataPath目录取得,再从streamingAssetsPath读书
        /// </summary>
        /// <returns>The new all text.</returns>
        /// <param name="fName">F name.</param>
        public static IEnumerator readNewAllTextAsyn(string fName, object OnGet)
        {
            string buff = "";

#if UNITY_WEBGL
            if (!CLCfgBase.self.isEditMode)
            {
                byte[] bytes = CLPreLoadRes4Webgl.getContent(fName);
                if (bytes != null)
                {
                    buff = Encoding.UTF8.GetString(bytes);
                }
            }
            else
            {
                buff = readNewAllText(fName);
            }
            yield return(null);
#else
            string fPath = CLPathCfg.persistentDataPath + "/" + fName;
            if (File.Exists(fPath))
            {
                yield return(null);

                buff = File.ReadAllText(fPath);
            }
            else
            {
                fPath = Application.streamingAssetsPath + "/" + fName;
                if (Application.platform == RuntimePlatform.Android)
                {
                    WWW www = new WWW(Utl.urlAddTimes(fPath));
                    yield return(www);

                    buff = www.text;
                    www.Dispose();
                    www = null;
                }
                else
                {
                    yield return(null);

                    if (File.Exists(fPath))
                    {
                        buff = File.ReadAllText(fPath);
                    }
                }
            }
#if UNITY_EDITOR
            if (buff == null)
            {
                Debug.LogError("Get null content == " + fPath);
            }
#endif
#endif
            Utl.doCallback(OnGet, buff);
        }
Exemple #2
0
        public IEnumerator exeCallback(object cbFunc)
        {
            yield return(null);

            if (cbFunc != null)
            {
                Utl.doCallback(cbFunc, this);
            }
        }
Exemple #3
0
        /// <summary>
        /// Moving the specified deltaTime.处理移动
        /// </summary>
        /// <param name="deltaTime">Delta time.会根据不同的情况传入</param>
        protected void moving(float deltaTime)
        {
            if (pathList == null || nextPahtIndex >= pathList.Count)
            {
                Debug.LogError("moving error");
                if (pathList == null)
                {
                    Debug.LogError("pathList == null!");
                }

                stopMove();
                Utl.doCallback(onArrivedCallback);
                return;
            }

            movePersent += (deltaTime * speed * 0.3f * offsetSpeed);
            if (movePersent >= 1)
            {
                movePersent      = 1;
                finishOneSubPath = true;
            }
            if (turningSpeed > 0)
            {
                rotateTowards(diff4Moving, false);
            }
            mTransform.position = fromPos4Moving + diff4Moving * movePersent;

            Utl.doCallback(onMovingCallback);

            if (nextPahtIndex == pathList.Count - 1)
            {
                //最后一段路径,即将要到达目的地
                if (finishOneSubPath ||
                    Vector3.Distance(mTransform.position, pathList[pathList.Count - 1]) <= endReachedDistance)
                {
                    stopMove();
                    Utl.doCallback(onArrivedCallback);
                }
            }
            else
            {
                if (finishOneSubPath)
                {
                    //移动完成一段路径,进入下一段路径的准备(一些变量的初始化)
                    nextPahtIndex++;
                    movePersent      = 0;
                    finishOneSubPath = false;
                    fromPos4Moving   = pathList[nextPahtIndex - 1];
                    diff4Moving      = pathList[nextPahtIndex] - pathList[nextPahtIndex - 1];
                    offsetSpeed      = 1.0f / Vector3.Distance(pathList[nextPahtIndex - 1], pathList[nextPahtIndex]);
                    if (turningSpeed <= 0)
                    {
                        rotateTowards(diff4Moving, true);
                    }
                }
            }
        }
Exemple #4
0
        // Update is called once per frame
        public virtual void FixedUpdate()
        {
            if (!isFireNow)
            {
                return;
            }
            if (!isFollow)
            {
                curveTime += Time.fixedDeltaTime * speed * 10 * magnitude;
                subDiff    = v3Diff * curveSpeed.Evaluate(curveTime);
                //				subDiff.y += high * curveHigh.Evaluate (curveTime);
                subDiff += highV3 * curveHigh.Evaluate(curveTime);
                if (!isMulHit && haveCollider)
                {
                    if (Physics.Raycast(transform.position, v3Diff, out hitInfor, 1f))
                    {
                        OnTriggerEnter(hitInfor.collider);
                    }
                }

                if (needRotate && subDiff.magnitude > 0.001f)
                {
                    Utl.RotateTowards(transform, origin + subDiff - transform.position);
                }
                transform.position = origin + subDiff;
                if (curveTime >= 1f)
                {
                    hitTarget = null;
                    onFinishFire(true);
                }
            }
            else
            {
                if (target == null || target.isDead ||
                    (RefreshTargetMSec > 0 &&
                     (DateEx.nowMS - lastResetTargetTime >= RefreshTargetMSec))
                    )
                {
                    lastResetTargetTime = DateEx.nowMS;
                    resetTarget();
                }
                subDiff = CalculateVelocity(transform.position);
                if (!isMulHit)
                {
                    if (Physics.Raycast(transform.position, v3Diff, out hitInfor, 1f))
                    {
                        OnTriggerEnter(hitInfor.collider);
                    }
                }
                //Rotate towards targetDirection (filled in by CalculateVelocity)
                if (targetDirection != Vector3.zero)
                {
                    Utl.RotateTowards(transform, targetDirection, turningSpeed);
                }
                transform.Translate(subDiff.normalized * Time.fixedDeltaTime * speed * 10, Space.World);
            }
        }
Exemple #5
0
 static void initFailed(params object[] param)
 {
     if (progressCallback != null)
     {
         Utl.doCallback(progressCallback, needUpgradeVerver.Count, progress, null);
     }
     loadPriorityVer();
     loadOtherResVer(false);
 }
Exemple #6
0
 public void onFinishFire(bool needRelease)
 {
     if (needRelease)
     {
         isFireNow = false;
         stop();
     }
     Utl.doCallback(onFinishCallback, this);
 }
Exemple #7
0
        /// <summary>
        /// Starts the GP.
        /// </summary>
        /// <returns>The GP.</returns>
        /// <param name="callback">Callback.</param>
        /// callback(errMsg, LocationInfo localInfor);
        /// LocationInfo
        ///     属性如下:
        ///         (1) altitude -- 海拔高度
        ///         (2) horizontalAccuracy -- 水平精度
        ///         (3) latitude -- 纬度
        ///         (4) longitude -- 经度
        ///         (5) timestamp -- 最近一次定位的时间戳,从1970开始
        ///         (6) verticalAccuracy -- 垂直精度
        public static IEnumerator StartGPS(float desired, object callback)
        {
            // Input.location 用于访问设备的位置属性(手持设备), 静态的LocationService位置
            // LocationService.isEnabledByUser 用户设置里的定位服务是否启用
            string errMsg = "";

            if (!Input.location.isEnabledByUser)
            {
                errMsg = "isEnabledByUser value is:" + Input.location.isEnabledByUser.ToString() + " Please turn on the GPS";
            }
            else
            {
                // LocationService.Start() 启动位置服务的更新,最后一个位置坐标会被使用

                /*void Start(float desiredAccuracyInMeters = 10f, float updateDistanceInMeters = 10f);
                 * 参数详解:
                 * desiredAccuracyInMeters  服务所需的精度,以米为单位。如果使用较高的值,比如500,那么通常不需要打开GPS芯片(比如可以利用信号基站进行三角定位),从而节省电池电量。像5-10这样的值,可以被用来获得最佳的精度。默认值是10米。
                 * updateDistanceInMeters  最小距离(以米为单位)的设备必须横向移动前Input.location属性被更新。较高的值,如500意味着更少的开销。默认值是10米。
                 */
                if (Input.location.status == LocationServiceStatus.Failed ||
                    Input.location.status == LocationServiceStatus.Stopped)
                {
                    Input.location.Start(desired);

                    int maxWait = 20;
                    while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
                    {
                        // 暂停协同程序的执行(1秒)
                        yield return(new WaitForSeconds(1));

                        maxWait--;
                    }

                    if (maxWait < 1)
                    {
                        errMsg = "Init GPS service time out";
                    }
                    else if (Input.location.status == LocationServiceStatus.Failed)
                    {
                        errMsg = "Unable to determine device location";
                    }
                    else
                    {
                        errMsg = "";
                        Debug.Log("--------N:" + Input.location.lastData.latitude + " E:" + Input.location.lastData.longitude);
//					yield return new WaitForSeconds(1);
                    }
                }
                Debug.Log("======N:" + Input.location.lastData.latitude + " E:" + Input.location.lastData.longitude);
//			yield return new WaitForSeconds(1);
            }

            Utl.doCallback(callback, errMsg, Input.location.lastData);
            //		StopGPS ();
        }
 public override void OnClick()
 {
     try {
         if (onClickCallback != null)
         {
             Utl.doCallback(onClickCallback, this);
         }
         base.OnClick();
     } catch (System.Exception e) {
         Debug.LogError(e);
     }
 }
Exemple #9
0
        static void checkVervers()
        {
            progress = 0;
            needUpgradeVerver.Clear();
            isNeedUpgradePriority = false;
            string    ver      = null;
            ArrayList keysList = MapEx.keys2List(serververVer);
            int       count    = keysList.Count;
            string    basePath = CLPathCfg.self.basePath;
            string    key      = "";

            for (int i = 0; i < count; i++)
            {
                key = keysList[i] as string;

                ver = MapEx.getString(localverVer, key); //实际上这个时间localverVer是空的
                if (ver == null || ver != MapEx.getString(serververVer, key))
                {
                    if (!key.Contains(PStr.b().a(basePath).a("/ui/panel").e()) &&
                        !key.Contains(PStr.b().a(basePath).a("/ui/cell").e()) &&
                        !key.Contains(PStr.b().a(basePath).a("/ui/other").e()))
                    {
                        MapEx.set(needUpgradeVerver, key, false);
                    }
                }
            }
            keysList.Clear();
            keysList = null;

            if (needUpgradeVerver.Count > 0)
            {
                if (progressCallback != null)
                {
                    Utl.doCallback(progressCallback, needUpgradeVerver.Count, 0);
                }

                keysList = MapEx.keys2List(needUpgradeVerver);
                count    = keysList.Count;
                key      = "";
                for (int i = 0; i < count; i++)
                {
                    key = keysList[i] as string;
                    getVerinfor(key, MapEx.getString(serververVer, key));
                }
                keysList.Clear();
                keysList = null;
            }
            else
            {
                loadPriorityVer();
                loadOtherResVer(true);
            }
        }
Exemple #10
0
        static void onGetVerinfor(params object[] param)
        {
            byte[] content = param[0] as byte[];
            object orgs    = param[1];

            if (content != null)
            {
                string fPath = orgs as string;
                progress = progress + 1;
                MapEx.set(localverVer, fPath, MapEx.getString(serververVer, fPath));

                string fName = PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(newestVerPath).a("/").a(fPath).e();
                if (Path.GetFileName(fName) == "priority.ver")
                {
                    //-- 优先更新需要把所有资源更新完后才记录
                    isNeedUpgradePriority = true;
                    serverPriorityVer     = CLVerManager.self.toMap(content);
                    CLVerManager.self.localPriorityVer = serverPriorityVer;
                }
                else
                {
                    otherResVerNew = CLVerManager.self.toMap(content);
                    CLVerManager.self.otherResVerNew = otherResVerNew;
                }

                MapEx.set(needUpgradeVerver, fPath, true);

                if (progressCallback != null)
                {
                    Utl.doCallback(progressCallback, needUpgradeVerver.Count, progress);
                }

                //-- if (isFinishAllGet()) then
                if (needUpgradeVerver.Count == progress)
                {
                    if (!isNeedUpgradePriority)
                    {
                        //-- 说明没有优先资源需要更新,可以不做其它处理了
                        //--同步到本地
                        loadPriorityVer();
                        loadOtherResVer(true);
                    }
                    else
                    {
                        checkPriority(); //--处理优先资源更新
                    }
                }
            }
            else
            {
                initFailed();
            }
        }
Exemple #11
0
        IEnumerator doInvoke4Lua(object callbakFunc, float sec, object orgs, int index)
        {
            yield return(new WaitForSeconds(sec));

            try {
                rmCoroutine(callbakFunc, index);
                Utl.doCallback(callbakFunc, orgs);
            } catch (System.Exception e) {
                string msg = "call err:doInvoke4Lua" + ",callbakFunc=[" + callbakFunc + "]";
                Debug.LogError(msg);
                Debug.LogError(e);
            }
        }
Exemple #12
0
        public void prepareOneSprite4BorrowMode(UIAtlas atlas, string spriteName, object callback, object orgs)
        {
            UISpriteData sd = atlas.getSpriteBorrowMode(spriteName);

            if (sd != null && MapEx.get(UIAtlas.assetBundleMap, sd.path) != null)
            {
                Utl.doCallback(callback, null, spriteName, orgs);
            }
            else
            {
                atlas.borrowSpriteByname(spriteName, null, callback, orgs);
            }
        }
Exemple #13
0
 public void init(object finishCallback, object orgs, object progressCallback)
 {
     this.progressCallback = progressCallback;
     if (isAllAssetsLoaded || isDonnotResetAssets)
     {
         Utl.doCallback(finishCallback, orgs);
     }
     else
     {
         OnFinishSetCallbacks.add(gameObject.GetInstanceID().ToString(), finishCallback, orgs);
         resetAssets();
     }
 }
Exemple #14
0
        /// <summary>
        /// Resets the chat list.聊天列表
        /// </summary>
        public static void resetChatList(GameObject grid, GameObject prefabChild, ArrayList list,
                                         System.Type itype, float offsetY, object initCallback)
        {
            if (list == null)
            {
                return;
            }

            //NGUITools.SetActive(grid, true);
            int         cellObjCount = grid.transform.childCount;     //grid.GetComponentsInChildren(itype).Length;
            GameObject  go           = null;
            BoxCollider bc           = null;
            float       anchor       = 0;
            Vector3     pos          = Vector3.zero;
            int         i            = 0;

            for (i = list.Count - 1; i >= 0; i--)
            {
                if (i < cellObjCount)
                {
#if UNITY_5_6_OR_NEWER
                    go = grid.transform.Find(i.ToString()).gameObject;
#else
                    go = grid.transform.FindChild(i.ToString()).gameObject;
#endif
                    NGUITools.SetActive(go, true);
                }
                else
                {
                    go      = NGUITools.AddChild(grid.gameObject, prefabChild);
                    go.name = i.ToString();
                }
                Utl.doCallback(initCallback, go.GetComponent <CLCellBase> (), list [i]);

                NGUITools.AddWidgetCollider(go);                                //设置collider是为了得到元素的高度以便计算,同时也会让碰撞区适合元素大小
                bc      = go.GetComponent(typeof(BoxCollider)) as  BoxCollider;
                pos     = go.transform.localPosition;
                anchor += (bc.size.y + offsetY);
                pos.y   = anchor;
                go.transform.localPosition = pos;
            }
            for (i = list.Count; i < cellObjCount; i++)
            {
#if UNITY_5_6_OR_NEWER
                go = grid.transform.Find(i.ToString()).gameObject;
#else
                go = grid.transform.FindChild(i.ToString()).gameObject;
#endif
                NGUITools.SetActive(go, false);
            }
        }
Exemple #15
0
 /// <summary>
 /// Begains the move.
 /// </summary>
 public virtual void startMove()
 {
     canMove = false;
     if (pathList == null || pathList.Count < 2)
     {
         Debug.LogWarning("Path list error!");
         return;
     }
     if (Vector3.Distance(mTransform.position, pathList[0]) < 0.001f)
     {
         //说明是在原点
         movePersent      = 0;
         finishOneSubPath = false;
         fromPos4Moving   = pathList[0];
         diff4Moving      = pathList[1] - pathList[0];
         offsetSpeed      = 1.0f / Vector3.Distance(pathList[0], pathList[1]);
         nextPahtIndex    = 1;
         rotateTowards(diff4Moving, true);
         canMove = true;
     }
     else if (Vector3.Distance(mTransform.position, pathList[pathList.Count - 1]) <= endReachedDistance)
     {
         //到达目标点
         Utl.doCallback(onFinishSeekCallback);
         return;
     }
     else
     {
         float dis  = 0;
         float dis1 = 0;
         float dis2 = 0;
         for (int i = 1; i < pathList.Count; i++)
         {
             dis  = Vector3.Distance(pathList[i - 1], pathList[i]);
             dis1 = Vector3.Distance(mTransform.position, pathList[i - 1]);
             dis2 = Vector3.Distance(mTransform.position, pathList[i]);
             if (Mathf.Abs(dis - (dis1 + dis2)) < 0.001f)
             {
                 movePersent      = dis1 / dis;
                 finishOneSubPath = false;
                 nextPahtIndex    = i;
                 fromPos4Moving   = pathList[i - 1];
                 diff4Moving      = pathList[i] - pathList[i - 1];
                 offsetSpeed      = 1.0f / Vector3.Distance(pathList[i - 1], pathList[i]);
                 rotateTowards(diff4Moving, true);
                 canMove = true;
                 break;
             }
         }
     }
 }
        /// <summary>
        /// Apply the dragging momentum.
        /// </summary>
        void LateUpdate()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif
            if (target == null)
            {
                return;
            }
            float delta = RealTime.deltaTime;

            mMomentum -= mScroll;
            mScroll    = NGUIMath.SpringLerp(mScroll, Vector3.zero, 20f, delta);

            // No momentum? Exit.
            if (mMomentum.magnitude > 0.0001f)
            {
                if (!mPressed)
                {
                    // Apply the momentum
                    Move(NGUIMath.SpringDampen(ref mMomentum, 9f, delta));

                    if (dragEffect == DragEffect.None)
                    {
                        CancelMovement();
                    }
                    else
                    {
                        CancelSpring();
                    }

                    // Dampen the momentum
                    NGUIMath.SpringDampen(ref mMomentum, 9f, delta);

                    // Cancel all movement (and snap to pixels) at the end
                    if (mMomentum.magnitude < 0.0001f)
                    {
                        CancelMovement();
                        Utl.doCallback(onEndDragMoveDelegate);
                    }
                }
                else
                {
                    NGUIMath.SpringDampen(ref mMomentum, 9f, delta);
                }
            }
        }
Exemple #17
0
        public void onFinish(params object[] obj)
        {
            if (returnAuto || obj == null)
            {
                CLEffectPool.returnObj(name, this);
                NGUITools.SetActive(gameObject, false);
                if (returnAuto)
                {
                    transform.parent = null;
                }
            }

            Utl.doCallback(finishCallback, this, finishCallbackPara);
        }
Exemple #18
0
        void onSeekAsynCallback(params object[] objs)
        {
            bool canReach = (bool)(objs[0]);

            pathList = objs[1] as List <Vector3>;

            //回调的第一个参数是路径,第二个参数是能否到达目标点
            Utl.doCallback(onFinishSeekCallback, pathList, canReach);

            if (autoMoveOnFinishSeek)
            {
                //开始移动
                startMove();
            }
        }
Exemple #19
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (isMoveToNow)
     {
         times += speed * Time.unscaledDeltaTime;
         if (times > 1)
         {
             times       = 1;
             isMoveToNow = false;
             Utl.doCallback(finishCallback, this);
         }
         panelList.transform.localPosition = fromListPos + diffListPos * moveCurve.Evaluate(times);
         panelList.clipOffset = fromOffset + diffOffset * moveCurve.Evaluate(times);
     }
 }
Exemple #20
0
        public virtual void RotateBullet()
        {
            if (needRotate)
            {
                curveTime2 += Time.fixedDeltaTime * speed * 10 * magnitude;
                subDiff2    = v3Diff * curveSpeed.Evaluate(curveTime2);
                //				subDiff.y += high * curveHigh.Evaluate (curveTime);
                subDiff2 += highV3 * curveHigh.Evaluate(curveTime2);

                if (subDiff2.magnitude > 0.01)
                {
                    Utl.RotateTowards(transform, origin + subDiff2 - transform.position);
                }
            }
        }
Exemple #21
0
        static void checkPriority()
        {
            localPriorityVer = new Hashtable();

            progress = 0;
            needUpgradeVerver.Clear();
            needUpgradePrioritis.Clear();
            string    ver      = null;
            ArrayList keysList = MapEx.keys2List(serverPriorityVer);
            string    key      = null;
            int       count    = keysList.Count;

            for (int i = 0; i < count; i++)
            {
                key = keysList[i] as string;
                ver = MapEx.getString(localPriorityVer, key);
                //实际上这个时间localverVer是空的,因此其实就是取得所有优先资源,但是因为了加了版本号,所以可以使用cdn,或者本地缓存什么的
                if (ver == null || ver != MapEx.getString(serverPriorityVer, key))
                {
                    MapEx.set(needUpgradeVerver, key, false);
                    needUpgradePrioritis.Enqueue(key);
                }
            }
            keysList.Clear();
            keysList = null;

            if (needUpgradePrioritis.Count > 0)
            {
                haveUpgrade = true;
                CLVerManager.self.haveUpgrade = true;
                if (progressCallback != null)
                {
                    Utl.doCallback(progressCallback, needUpgradeVerver.Count, 0);
                }
                getPriorityFiles(needUpgradePrioritis.Dequeue() as string);
            }
            else
            {
                //--同步总的版本管理文件到本地
                //MemoryStream ms = new MemoryStream();
                //B2OutputStream.writeMap(ms, localverVer);
                //string vpath = PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(mVerverPath).e();
                //FileEx.CreateDirectory(Path.GetDirectoryName(vpath));
                //File.WriteAllBytes(vpath, ms.ToArray());

                loadOtherResVer(true);
            }
        }
Exemple #22
0
 /// <summary>
 /// Reports the progress.设置成就
 /// </summary>
 /// <param name="activeId">Active identifier.</param>
 /// <param name="progress">Progress.</param>
 /// <param name="callback">Callback.</param>
 /// <param name="orgs">Orgs.</param>
 public static void reportProgress(string activeId, double progress, object callback, object orgs)
 {
                 #if UNITY_IPHONE || UNITY_IOS
     if (Social.localUser.authenticated)
     {
         Social.ReportProgress(activeId, progress, success => {
             Utl.doCallback(callback, success, orgs);
         });
     }
     else
     {
         Debug.LogWarning("Social.localUser.authenticated==" + Social.localUser.authenticated);
         Utl.doCallback(callback, false, orgs, "Social.localUser.authenticated==" + Social.localUser.authenticated);
     }
                 #endif
 }
Exemple #23
0
 /// <summary>
 /// Reports the score.排行榜设置分数
 /// </summary>
 /// <param name="sore">Sore.</param>
 /// <param name="board">Board.</param>
 /// <param name="callback">Callback.</param>
 /// <param name="orgs">Orgs.</param>
 public static void reportScore(long sore, string board, object callback, object orgs)
 {
                 #if UNITY_IPHONE || UNITY_IOS
     if (Social.localUser.authenticated)
     {
         Social.ReportScore(sore, board, success => {
             Utl.doCallback(callback, success, orgs);
         });
     }
     else
     {
         Debug.LogWarning("Social.localUser.authenticated==" + Social.localUser.authenticated);
         Utl.doCallback(callback, false, orgs, "Social.localUser.authenticated==" + Social.localUser.authenticated);
     }
                 #endif
 }
Exemple #24
0
        static IEnumerator DelayedCallback(AudioClip clip, float time, object callback)
        {
            string cName = "";

            if (clip != null)
            {
                cName = clip.name;
            }
            yield return(new WaitForSeconds(time));

            CLSoundPool.returnObj(cName);
            if (clip != null)
            {
                Utl.doCallback(callback, clip);
            }
        }
Exemple #25
0
        public void switchByName(string cellName, Animator animator, object callback)
        {
            if (!isInited)
            {
                init();
            }
            int index = MapEx.getInt(mapIndex, cellName);

            if (needSwitchController)
            {
                if (animator != null)
                {
                    animator.runtimeAnimatorController = animatorControllers [index];
                }
                else
                {
                    Debug.LogError("animator is null");
                }
            }

            if (switchType == CLSwitchType.showOrHide)
            {
                for (int i = 0; i < partObjs.Count; i++)
                {
                    if (i == index)
                    {
                        NGUITools.SetActive(partObjs [i], true);
                    }
                    else
                    {
                        NGUITools.SetActive(partObjs [i], false);
                    }
                }
                Utl.doCallback(callback);
            }
            else if (switchType == CLSwitchType.switchShader)
            {
                if (render.sharedMaterial != null)
                {
                    string mName = render.sharedMaterial.name;
//					mName = mName.Replace(" (Instance)", "");
                    CLMaterialPool.returnObj(mName);
                    render.sharedMaterial = null;
                }
                setMat(render, materialNames [index], callback);
            }
        }
Exemple #26
0
        public static void onGetTexture(params object[] paras)
        {
            string name = "";

            try
            {
                Texture   tex       = paras[0] as Texture;
                NewList   list      = paras[1] as NewList;
                Material  mat       = list[0] as Material;
                int       i         = (int)(list[6]);
                ArrayList propNames = list[3] as ArrayList;
                string    propName  = propNames[i].ToString();

                //				name = paras [0].ToString ();
                if (tex == null)
                {
                    ArrayList texPaths = list[5] as ArrayList;
                    Debug.LogError("Get tex is null." + mat.name + "===" + texPaths[i]);
                }
                else
                {
                    name = tex.name;
                    // 设置material对应属性的texture
                    mat.SetTexture(propName, tex);
                }
                int count = propNames.Count;
                i++;
                if (i >= count)
                {
                    pool.finishSetPrefab(mat);
                    //finished
                    Callback cb   = list[1] as Callback;
                    object   agrs = list[2];
                    Utl.doCallback(cb, mat, agrs);
                    ObjPool.listPool.returnObject(list);
                }
                else
                {
                    list[6] = i;
                    doresetTexRef(list);
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError("name==========" + name + "==" + e);
            }
        }
Exemple #27
0
        public void onGetNewstRes(UnityWebRequest www, string url, string path, CLAssetType type, object content, bool needSave, object onGetAsset, bool autoRealseAB, params object[] originals)
        {
            try
            {
                if (needSave)
                {
                    //说明是需要下载的资源
                    //if (www != null && content == null && (MapEx.getInt(wwwTimesMap, path) + 1) < downLoadTimes4Failed)
                    //{
                    //    //需要下载资源时,如查下载失败,且少于失败次数,则再次下载
                    //    wwwTimesMap[path] = MapEx.getInt(wwwTimesMap, path) + 1;
                    //    doGetContent(path, url, needSave, type, onGetAsset, autoRealseAB, originals);
                    //    return;
                    //}
                    rmWWW(url);
                }
                if (content == null)
                {
                    Debug.LogError("get newstRes is null. url==" + url);
                }
                Utl.doCallback(onGetAsset, path, content, originals);


                if (autoRealseAB && content != null && type == CLAssetType.assetBundle)
                {
                    AssetBundle ab = content as AssetBundle;
                    if (ab != null)
                    {
                        ab.Unload(false);
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(e + "\n" + path);
            }


            if (www != null)
            {
                www.Dispose();
                www = null;
            }

            wwwMap[path] = false;
            //wwwTimesMap[path] = 0;
        }
Exemple #28
0
        /// <summary>
        /// Seek the specified toPos.寻路
        /// </summary>
        /// <returns>The seek.路径列表</returns>
        /// <param name="toPos">To position.</param>
        public virtual List <Vector3> seek(Vector3 toPos)
        {
            targetPos = toPos;
            canMove   = false;
            pathList.Clear();
            bool canReach = mAStarPathSearch.searchPath(mTransform.position, toPos, ref pathList);

            //回调的第一个参数是路径,第二个参数是能否到达目标点
            Utl.doCallback(onFinishSeekCallback, pathList, canReach);

            if (autoMoveOnFinishSeek)
            {
                //开始移动
                startMove();
            }
            return(pathList);
        }
Exemple #29
0
        void OnClick()
        {
            mainCamera         = MyMainCamera.current;
            mainCamera.enabled = true;
            mainCamera.Update();
            mainCamera.LateUpdate();
//	#if UNITY_EDITOR
//		mainCamera.ProcessMouse();
//		#else
//		mainCamera.ProcessTouches();
//#endif
            if (MyMainCamera.lastHit.collider != null)
            {
            }

            Utl.doCallback(onClickCallback);
        }
Exemple #30
0
        void doInvokeByUpdate()
        {
            int         count = invokeByUpdateList.Count;
            NewList     list  = null;
            object      callbakFunc;
            object      orgs;
            float       sec;
            int         index = 0;
            LuaFunction func  = null;

            while (index < invokeByUpdateList.Count)
            {
                list = (invokeByUpdateList [index]) as NewList;
                if (list == null)
                {
                    continue;
                }
                callbakFunc = list [0];
                orgs        = list [1];
                sec         = (float)(list [2]);
                if (sec <= Time.unscaledTime)
                {
                    if (callbakFunc is string)
                    {
                        func = getLuaFunction(callbakFunc.ToString());
                        Utl.doCallback(func, orgs);
                    }
                    else if (callbakFunc is LuaFunction)
                    {
                        func = (LuaFunction)callbakFunc;
                        Utl.doCallback(func, orgs);
                    }
                    else if (callbakFunc is Callback)
                    {
                        ((Callback)callbakFunc)(orgs);
                    }
                    invokeByUpdateList.RemoveAt(index);
                    ObjPool.listPool.returnObject(list);
                }
                else
                {
                    index++;
                }
            }
            list = null;
        }