状态栏显示帧数

This commit is contained in:
ALIENJACK\alien 2024-11-19 13:09:53 +08:00
parent 36c461562e
commit b54de1e162
6 changed files with 113 additions and 4 deletions

View File

@ -114,7 +114,7 @@ namespace AxiReplay
if (frameGap > 10000) return 0; if (frameGap > 10000) return 0;
int skip = 0; int skip = 0;
if (frameGap <= 2) skip = 0; if (frameGap <= 2) skip = 0;
if (frameGap > 2 && frameGap < 6) skip = 1 + 1; if (frameGap > 2 && frameGap < 6) skip = 1 + 1;
else if (frameGap > 7 && frameGap < 12) skip = 2 + 1; else if (frameGap > 7 && frameGap < 12) skip = 2 + 1;

View File

@ -265,6 +265,7 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 4541943946029862829}
- {fileID: 2005113594707322973} - {fileID: 2005113594707322973}
- {fileID: 4195056312044822544} - {fileID: 4195056312044822544}
- {fileID: 1746243318642131728} - {fileID: 1746243318642131728}
@ -320,6 +321,7 @@ MonoBehaviour:
imgPower2: {fileID: 7232861150095392420} imgPower2: {fileID: 7232861150095392420}
imgPower3: {fileID: 6694955234077232327} imgPower3: {fileID: 6694955234077232327}
DelayValue: {fileID: 6486398873987280650} DelayValue: {fileID: 6486398873987280650}
FPS: {fileID: 2545793518460288919}
--- !u!1 &5629957813601835122 --- !u!1 &5629957813601835122
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -352,7 +354,7 @@ RectTransform:
m_Children: m_Children:
- {fileID: 1735688216191931001} - {fileID: 1735688216191931001}
m_Father: {fileID: 5353336693430589123} m_Father: {fileID: 5353336693430589123}
m_RootOrder: 2 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
@ -417,6 +419,85 @@ MonoBehaviour:
m_FlexibleWidth: -1 m_FlexibleWidth: -1
m_FlexibleHeight: -1 m_FlexibleHeight: -1
m_LayoutPriority: 1 m_LayoutPriority: 1
--- !u!1 &5634255875545658264
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4541943946029862829}
- component: {fileID: 3282993275160308839}
- component: {fileID: 2545793518460288919}
m_Layer: 5
m_Name: FPS
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4541943946029862829
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5634255875545658264}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 5353336693430589123}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 53}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3282993275160308839
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5634255875545658264}
m_CullTransparentMesh: 1
--- !u!114 &2545793518460288919
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5634255875545658264}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 30
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 3
m_MaxSize: 55
m_Alignment: 5
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: FPS:60
--- !u!1 &6140890295709974557 --- !u!1 &6140890295709974557
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -523,7 +604,7 @@ RectTransform:
- {fileID: 1777012203952456443} - {fileID: 1777012203952456443}
- {fileID: 7158194035478552859} - {fileID: 7158194035478552859}
m_Father: {fileID: 5353336693430589123} m_Father: {fileID: 5353336693430589123}
m_RootOrder: 0 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
@ -586,7 +667,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 5353336693430589123} m_Father: {fileID: 5353336693430589123}
m_RootOrder: 1 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}

View File

@ -15,6 +15,7 @@ namespace AxibugEmuOnline.Client
void SetupScheme(); void SetupScheme();
void StartGame(RomFile romFile); void StartGame(RomFile romFile);
void DoReset(); void DoReset();
uint Frame { get; }
} }
public static class IEnumCoreTool public static class IEnumCoreTool

View File

@ -13,6 +13,11 @@ namespace AxibugEmuOnline.Client.Manager
/// 但是Equals方法可以,所以,这个接口判断为空请使用Equals /// 但是Equals方法可以,所以,这个接口判断为空请使用Equals
/// </summary> /// </summary>
private IEmuCore m_emuCore; private IEmuCore m_emuCore;
/// <summary>
/// unity的c#实现有bug,以接口类型保存的monobehaviour引用,!=和==运算符没有调用到monobehaviour重写过的运算符
/// 但是Equals方法可以,所以,这个接口判断为空请使用Equals
/// </summary>
public IEmuCore Core => m_emuCore;
public AppEmu() public AppEmu()
{ {

View File

@ -169,5 +169,7 @@ namespace AxibugEmuOnline.Client
UnityEditor.EditorUtility.SetDirty(db); UnityEditor.EditorUtility.SetDirty(db);
UnityEditor.AssetDatabase.SaveAssets(); UnityEditor.AssetDatabase.SaveAssets();
} }
public uint Frame => NesCore.FrameCount;
} }
} }

View File

@ -12,6 +12,7 @@ public class XMBTopGroup : MonoBehaviour
public Image imgPower2; public Image imgPower2;
public Image imgPower3; public Image imgPower3;
public Text DelayValue; public Text DelayValue;
public Text FPS;
void OnEnable() void OnEnable()
{ {
@ -29,6 +30,25 @@ public class XMBTopGroup : MonoBehaviour
RefreshTime(); RefreshTime();
RefreshPower(); RefreshPower();
RefreshDelay(); RefreshDelay();
RefreshFps();
}
(uint lastFrame, float lastTime) m_lastFrameInfo;
private void RefreshFps()
{
if (App.emu.Core.IsNull())
FPS.gameObject.SetActiveEx(false);
else
{
FPS.gameObject.SetActiveEx(true);
var gap = App.emu.Core.Frame - m_lastFrameInfo.lastFrame;
var time = Time.realtimeSinceStartup - m_lastFrameInfo.lastTime;
var fps = gap / time;
FPS.text = $"FPS:{fps:.#}";
m_lastFrameInfo.lastFrame = App.emu.Core.Frame;
m_lastFrameInfo.lastTime = Time.realtimeSinceStartup;
}
} }
private void RefreshDelay() private void RefreshDelay()