骑行界面字体

This commit is contained in:
lishuo committed 2021-04-19 18:03:04 +08:00
1 parent af63072f29
commit 82923fe4f8
13 files changed
+2390 -2188

No files matched your search

@@ -22,6 +22,7 @@ public class CyclingController : DeviceServiceMonoBase
public GameObject UIObject;
public RouteResultParam selectParamModel;
public RouteResult routeResult;
public int preticks;
#region 参数
@@ -35,6 +36,10 @@ public class CyclingController : DeviceServiceMonoBase
private MapApi mapApi;
private Route mapRoute;
public DateTime startTime;
public DateTime endTime;
public bool isQuit;
public bool isPause;
#endregion
GameObject loadingcanvas;
void Awake()
@@ -111,6 +116,40 @@ public class CyclingController : DeviceServiceMonoBase
}
}
#region 游戏状态控制
//开始骑行
public void SetStart()
{
if (!isPause)
{
isStart = true;
startTime = DateTime.Now;
}
else
{
SetContinue();
}
}
//继续骑行
public void SetContinue()
{
isStart = true;
isPause = false;
}
//暂停骑行
public void SetPause()
{
isStart = false;
isPause = true;
}
//退出或者完成骑行
public void SetQuit()
{
isStart = false;
isQuit = true;
}
#endregion
#region 数据处理
/// <summary>
/// 当前骑行数据的记录器
@@ -131,6 +170,50 @@ public class CyclingController : DeviceServiceMonoBase
{
return mapData;
}
public void Save(double totalDistance)
{
isStart = false;
string imageFileName = CaptureCamera(Camera.main, new Rect(Screen.width * 0f, Screen.height * 0f, Screen.width * 0.5f, Screen.height * 0.5f));
cyclingController.recorderData.StartTime = startTime;
cyclingController.recorderData.IsCompleted = totalDistance == mapData.TotalDistance;
cyclingController.recorderData.EndDistance = totalDistance;
cyclingController.recorderData.AntModelId = AntModelId;
cyclingController.recorderData.ManufacturerId = ManufacturerId;
cyclingController.recorderData.DeviceNumber = DeviceNumber;
cyclingController.recorderData.SaveData(cyclingModel, selectParamModel, imageFileName);
}
protected string CaptureCamera(Camera camera, Rect rect)
{
// 创建一个RenderTexture对象
RenderTexture rt = new RenderTexture((int)rect.width, (int)rect.height, 0);
// 临时设置相关相机的targetTexture为rt, 并手动渲染相关相机
camera.targetTexture = rt;
camera.Render();
//ps: --- 如果这样加上第二个相机,可以实现只截图某几个指定的相机一起看到的图像。
//ps: camera2.targetTexture = rt;
//ps: camera2.Render();
//ps: -------------------------------------------------------------------
// 激活这个rt, 并从中中读取像素。
RenderTexture.active = rt;
Texture2D screenShot = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGB24, false);
screenShot.ReadPixels(rect, 0, 0);// 注:这个时候,它是从RenderTexture.active中读取像素
screenShot.Apply();
// 重置相关参数,以使用camera继续在屏幕上显示
camera.targetTexture = null;
//ps: camera2.targetTexture = null;
RenderTexture.active = null; // JC: added to avoid errors
GameObject.Destroy(rt);
// 最后将这些纹理数据,成一个图片文件
byte[] bytes = screenShot.EncodeToPNG();
string filename = Application.dataPath + "/" + Guid.NewGuid().ToString() + ".png";
System.IO.File.WriteAllBytes(filename, bytes);
//Debug.Log(string.Format("截屏了一张照片: {0}", filename));
return filename;
}
public Vector2d GetCenterCoordinate()
{
return coordiantes;