コード例 #1
0
        //重建场景
        public void ReBuildScene()
        {
            if (!m_IsInitialized)
            {
                return;
            }
            if (detector == null)
            {
                GameObject obj = new GameObject("SceneNearFarDetector");
                detector = obj.AddComponent <SceneNearFarDetector>();
                obj.transform.position = Vector3.zero;
                GameObject player = GameObject.Find("ENTITY_OBJECT/PLAYER_MAIN");
                if (player != null && player.transform.childCount >= 1)
                {
                    obj.transform.position = player.transform.GetChild(0).position;
                }
            }

            m_OldRefreshPosition = detector.Position;
            m_CurrentDetector    = detector;
            //进行触发检测
            m_Tree.Trigger(detector, m_TriggerHandle);
        }
コード例 #2
0
 /// <summary>
 /// 刷新触发器
 /// </summary>
 /// <param name="detector">触发器</param>
 public void RefreshDetector(IDetector detector)
 {
     if (!m_IsInitialized)
     {
         return;
     }
     //只有坐标发生改变才调用
     if (m_OldRefreshPosition != detector.Position)
     {
         m_RefreshTime += Time.deltaTime;
         //达到刷新时间才刷新,避免区域更新频繁
         if (m_RefreshTime > m_MaxRefreshTime)
         {
             m_OldRefreshPosition = detector.Position;
             m_RefreshTime        = 0;
             m_CurrentDetector    = detector;
             //进行触发检测
             m_Tree.Trigger(detector, m_TriggerHandle);
             //标记超出区域的物体
             MarkOutofBoundsObjs();
             //m_IsInitLoadComplete = true;
         }
     }
     if (m_OldDestroyRefreshPosition != detector.Position)
     {
         if (m_PreDestroyObjectQueue != null && m_PreDestroyObjectQueue.Count >= m_MaxCreateCount && m_PreDestroyObjectQueue.Count > m_MinCreateCount)
         //if (m_PreDestroyObjectList != null && m_PreDestroyObjectList.Count >= m_MaxCreateCount)
         {
             m_DestroyRefreshTime += Time.deltaTime;
             if (m_DestroyRefreshTime > m_MaxDestroyTime)
             {
                 m_OldDestroyRefreshPosition = detector.Position;
                 m_DestroyRefreshTime        = 0;
                 //删除超出区域的物体
                 DestroyOutOfBoundsObjs();
             }
         }
     }
 }