骑行内存优化&设备连接点击优化
This commit is contained in:
1 parent
004410048f
commit
8b3dd7a40a
11 files changed
+7495
-2133
No files matched your search
@@ -51,6 +51,12 @@ namespace Assets.Scripts.Scenes
|
||||
App.MainDeviceAdapter.Dispose();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
private void OnApplicationPause(bool focus)
|
||||
{
|
||||
if (focus)
|
||||
|
||||
@@ -88,6 +88,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
void OnDestroy()
|
||||
{
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
}
|
||||
Transform target;
|
||||
GameObject watcher;
|
||||
@@ -107,6 +108,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
return OnlineHeadPanel;
|
||||
}
|
||||
Material Graph3d { get; set; }
|
||||
Material Graph4 { get; set; }
|
||||
Material Graph1 { get; set; }
|
||||
public Material Get3dGraph2()
|
||||
{
|
||||
if (Graph3d == null)
|
||||
@@ -115,6 +118,26 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
}
|
||||
return Graph3d;
|
||||
}
|
||||
|
||||
public Material GetMaterial4()
|
||||
{
|
||||
if (Graph4 == null)
|
||||
{
|
||||
Graph4 = Resources.Load<Material>("UI/Material/4");
|
||||
}
|
||||
return Graph4;
|
||||
}
|
||||
|
||||
|
||||
public Material GetMaterial1()
|
||||
{
|
||||
if (Graph1 == null)
|
||||
{
|
||||
Graph1 = Resources.Load<Material>("UI/Material/1");
|
||||
}
|
||||
return Graph1;
|
||||
}
|
||||
|
||||
Image CompetitionArrow { get; set; }
|
||||
public Image GetCompetitionArrow()
|
||||
{
|
||||
|
||||
@@ -86,8 +86,13 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
nearByItemscript.setName(item.Name);
|
||||
nearByItemscript.setRatio(item.KGWeight + "W/KG");
|
||||
nearByItemscript.setSpeed(item.Speed.ToString() + "KM/H");
|
||||
nearByItemscript.setHead(item.Headimage);
|
||||
if (cyclingController.currentPlayer.UserId == item.Id)
|
||||
{
|
||||
nearByItemscript.setHead(item.Headimage);
|
||||
}
|
||||
#if !(UNITY_IOS || UNITY_ANDROID)
|
||||
nearByItemscript.setCountry(cyclingController.GetCountryImageByName(item.Country));
|
||||
#endif
|
||||
nearByItemscript.setDistance(item.Near.ToString() + "KM");
|
||||
nearByItemscript.transform.SetSiblingIndex((int)item.Near);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
trailRenderer = FindObjectOfType<TrailRenderer>();
|
||||
//var color7 = Resources.Load<Material>("UI/Material/color7");
|
||||
var Graph2 = mainController.Get3dGraph2(); //Resources.Load<Material>("UI/Material/3dGraph2");
|
||||
trailRenderer.materials = new Material[] { Graph2 };
|
||||
trailRenderer.material = Graph2;//new Material[] { Graph2 };
|
||||
trailRenderer.time = 30;
|
||||
trailRenderer.startWidth = 1f;
|
||||
trailRenderer.endWidth = 1f;
|
||||
@@ -222,7 +222,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
_directionsGO.transform.SetParent(transform);
|
||||
var lineRender = _directionsGO.AddComponent<LineRenderer>();
|
||||
//lineRender.material = new Material(Shader.Find("Sprites/Default"));
|
||||
lineRender.material = Resources.Load<Material>("UI/Material/4");
|
||||
lineRender.material = mainController.GetMaterial4(); //Resources.Load<Material>("UI/Material/4");
|
||||
lineRender.endColor = new Color(0.1529412f, 0.8745098f, 0.8901961f, 1f);
|
||||
lineRender.startColor = new Color(0.1529412f, 0.8745098f, 0.8901961f, 1f);
|
||||
|
||||
@@ -258,10 +258,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
headPanel.transform.SetParent(graph.transform);
|
||||
headPanel.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
|
||||
}
|
||||
if (CurrentIndex == 1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int nextIndex = CurrentIndex;
|
||||
var viewIndex = chartDataSourceScript.GetViewIndex(nextIndex);
|
||||
//人物移动 停止条件 到中间且线未加载完
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
var lineRender = _directionsGO.AddComponent<LineRenderer>();
|
||||
//lineRender.material = new Material(Shader.Find("Sprites/Default"));
|
||||
//lineRender.material = Resources.Load<Material>("UI/Material/color8");
|
||||
lineRender.material = Resources.Load<Material>("UI/Material/1");
|
||||
lineRender.material = mainController.GetMaterial1(); //Resources.Load<Material>("UI/Material/1");
|
||||
lineRender.endColor = new Color(1, 1f, 1f, 0.65f);
|
||||
lineRender.startColor = new Color(1, 1f, 1f, 0.65f);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ using System;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class RouteController : MonoBehaviour
|
||||
public class RouteController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
AbstractMap _map;
|
||||
@@ -21,7 +21,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
Material _material;
|
||||
[SerializeField]
|
||||
[Range(1, 10)]
|
||||
private float UpdateFrequency = 0.1f;
|
||||
private float UpdateFrequency = 1f;
|
||||
|
||||
private int _counter;
|
||||
|
||||
@@ -31,33 +31,35 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
CyclingController cyclingCotroller;
|
||||
private bool initComplete = false;
|
||||
|
||||
Material Graph2 { get; set; }
|
||||
Material linematerial { get; set; }
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
if (_map == null)
|
||||
{
|
||||
_map = FindObjectOfType<AbstractMap>();
|
||||
}
|
||||
// _map.OnInitialized += _map_OnInitialized; ;
|
||||
//_map.OnUpdated += _map_OnUpdated; ;
|
||||
|
||||
|
||||
|
||||
// _map.OnInitialized += _map_OnInitialized; ;
|
||||
//_map.OnUpdated += _map_OnUpdated; ;
|
||||
Graph2 = Resources.Load<Material>("UI/Material/3dGraph2");
|
||||
linematerial = Resources.Load<Material>("UI/Material/3");
|
||||
}
|
||||
|
||||
private void _map_OnUpdated()
|
||||
{
|
||||
private void _map_OnUpdated()
|
||||
{
|
||||
Debug.Log("_map_OnUpdated");
|
||||
}
|
||||
}
|
||||
|
||||
private void _map_OnInitialized()
|
||||
{
|
||||
private void _map_OnInitialized()
|
||||
{
|
||||
Debug.Log("_map_OnInitialized");
|
||||
CreateRoute();
|
||||
}
|
||||
|
||||
private void _map_OnTileFinished(UnityTile obj)
|
||||
{
|
||||
|
||||
private void _map_OnTileFinished(UnityTile obj)
|
||||
{
|
||||
|
||||
if (!initComplete)
|
||||
{
|
||||
CreateRoute(obj);
|
||||
@@ -94,7 +96,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
void CreateRoute(UnityTile tile)
|
||||
{
|
||||
{
|
||||
var meshData = new MeshData();
|
||||
//var meshData = new MeshData();
|
||||
var dat = new List<Vector3>();
|
||||
var path = new List<Vector3>();
|
||||
|
||||
@@ -121,13 +123,13 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
if (diffAbs <= 200)
|
||||
{
|
||||
//if (!dat.Contains(item))
|
||||
dat.Add(item);
|
||||
dat.Add(item);
|
||||
}
|
||||
if (diff <= 0 && diff > -200)
|
||||
{
|
||||
item.y += 0.15f;
|
||||
//if (!dat.Contains(item))
|
||||
path.Add(item);
|
||||
path.Add(item);
|
||||
}
|
||||
}
|
||||
var feat = new VectorFeatureUnity();
|
||||
@@ -161,7 +163,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
bool foundTile = _map.MapVisualizer.ActiveTiles.TryGetValue(Conversions.LatitudeLongitudeToTileId(_map.CenterLatitudeLongitude.x, _map.CenterLatitudeLongitude.y, (int)_map.Zoom), out tile);
|
||||
if (foundTile)
|
||||
{
|
||||
var meshData = new MeshData();
|
||||
//var meshData = new MeshData();
|
||||
var dat = new List<Vector3>();
|
||||
|
||||
var mapData = cyclingCotroller.GetMapData();
|
||||
@@ -188,16 +190,16 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
if (_directionsGO != null)
|
||||
{
|
||||
_directionsGO.Destroy();
|
||||
DestroyImmediate(_directionsGO);
|
||||
}
|
||||
_directionsGO = new GameObject("MapRoute");
|
||||
_directionsGO.transform.parent = transform;
|
||||
var lineRender = _directionsGO.AddComponent<LineRenderer>();
|
||||
//lineRender.material = new Material(Shader.Find("Sprites/Default"));
|
||||
lineRender.material = Resources.Load<Material>("UI/Material/3");
|
||||
lineRender.material = linematerial; //Resources.Load<Material>("UI/Material/3");
|
||||
var dat = feat.Points[0];
|
||||
ColorUtility.TryParseHtmlString("#FF2742", out Color c);
|
||||
lineRender.endColor = new Color(1,1,1,0.65f);
|
||||
lineRender.endColor = new Color(1, 1, 1, 0.65f);
|
||||
lineRender.startColor = new Color(1, 1, 1, 0.65f);
|
||||
|
||||
//设置宽度
|
||||
@@ -205,26 +207,26 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
lineRender.endWidth = 1.5f;
|
||||
lineRender.positionCount = dat.Count;
|
||||
lineRender.SetPositions(feat.Points[0].ToArray());
|
||||
lineRender.loop = false;
|
||||
lineRender.numCapVertices = 10;
|
||||
//lineRender.numCornerVertices = 30;
|
||||
lineRender.loop = false;
|
||||
lineRender.numCapVertices = 10;
|
||||
//lineRender.numCornerVertices = 30;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CreatPathRoute(List<Vector3> feat)
|
||||
{
|
||||
if (_pathRoute != null)
|
||||
{
|
||||
_pathRoute.Destroy();
|
||||
DestroyImmediate(_pathRoute);
|
||||
}
|
||||
_pathRoute = new GameObject("MapPathRoute");
|
||||
_pathRoute.transform.parent = transform;
|
||||
var lineRender = _pathRoute.AddComponent<LineRenderer>();
|
||||
//lineRender.material = new Material(Shader.Find("Sprites/Default"));
|
||||
//var color7 = Resources.Load<Material>("UI/Material/color7");
|
||||
var Graph2 = Resources.Load<Material>("UI/Material/3dGraph2");
|
||||
lineRender.materials = new Material[] { Graph2 };
|
||||
//var Graph2 = Resources.Load<Material>("UI/Material/3dGraph2");
|
||||
lineRender.material = Graph2;//new Material[] { Graph2 };
|
||||
lineRender.endColor = new Color(0.9764706f, 0.1882353f, 0.5254902f, 0.65f);
|
||||
lineRender.startColor = new Color(0.9764706f, 0.1882353f, 0.5254902f, 0.65f);
|
||||
|
||||
@@ -233,11 +235,11 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
lineRender.endWidth = 1f;
|
||||
lineRender.positionCount = feat.Count;
|
||||
lineRender.SetPositions(feat.ToArray());
|
||||
lineRender.loop = false;
|
||||
lineRender.numCapVertices = 10;
|
||||
//lineRender.numCornerVertices = 10;
|
||||
//
|
||||
lineRender.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
|
||||
lineRender.loop = false;
|
||||
lineRender.numCapVertices = 10;
|
||||
//lineRender.numCornerVertices = 10;
|
||||
//
|
||||
lineRender.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
|
||||
lineRender.allowOcclusionWhenDynamic = false;
|
||||
lineRender.textureMode = LineTextureMode.Tile;
|
||||
lineRender.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion;
|
||||
|
||||
Reference in new issue
Block a user