浏览代码

more work, cleanup of UI prefabs

/seans-add-link-xml
André McGrail 4 年前
当前提交
434d0103
共有 46 个文件被更改,包括 216 次插入92 次删除
  1. 40
      Assets/Scripts/GameSystem/AppSettings.cs
  2. 108
      Assets/Scripts/System/Benchmark.cs
  3. 131
      Assets/scenes/Testing/benchmark_island-flythrough.unity
  4. 5
      Packages/manifest.json
  5. 8
      Assets/Objects/UI/prefabs/InGame.meta
  6. 8
      Assets/Objects/UI/prefabs/MainMenu.meta
  7. 8
      Assets/Objects/UI/prefabs/Utility.meta
  8. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton.prefab
  9. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton.prefab.meta
  10. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton_Back.prefab
  11. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton_Back.prefab.meta
  12. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton_Finish.prefab
  13. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton_Finish.prefab.meta
  14. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton_Next.prefab
  15. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton_Next.prefab.meta
  16. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton_Race.prefab
  17. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton_Race.prefab.meta
  18. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton_Rematch.prefab
  19. 0
      /Assets/Objects/UI/prefabs/Utility/BaseButton_Rematch.prefab.meta
  20. 0
      /Assets/Objects/UI/prefabs/MainMenu/BoatRoom.prefab
  21. 0
      /Assets/Objects/UI/prefabs/MainMenu/BoatRoom.prefab.meta
  22. 0
      /Assets/Objects/UI/prefabs/MainMenu/MainMenuUI.prefab
  23. 0
      /Assets/Objects/UI/prefabs/MainMenu/MainMenuUI.prefab.meta
  24. 0
      /Assets/Objects/UI/prefabs/MainMenu/MenuOption.prefab
  25. 0
      /Assets/Objects/UI/prefabs/MainMenu/MenuOption.prefab.meta
  26. 0
      /Assets/Objects/UI/prefabs/MainMenu/MenuOption_BoatType.prefab
  27. 0
      /Assets/Objects/UI/prefabs/MainMenu/MenuOption_BoatType.prefab.meta
  28. 0
      /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Laps.prefab.meta
  29. 0
      /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Level.prefab
  30. 0
      /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Level.prefab.meta
  31. 0
      /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Reverse.prefab
  32. 0
      /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Reverse.prefab.meta
  33. 0
      /Assets/Objects/UI/prefabs/InGame/PlayerMapMarker.prefab
  34. 0
      /Assets/Objects/UI/prefabs/InGame/PlayerMapMarker.prefab.meta
  35. 0
      /Assets/Objects/UI/prefabs/InGame/PlayerMarker.prefab
  36. 0
      /Assets/Objects/UI/prefabs/InGame/PlayerMarker.prefab.meta
  37. 0
      /Assets/Objects/UI/prefabs/InGame/RaceStats_Player.prefab
  38. 0
      /Assets/Objects/UI/prefabs/InGame/RaceStats_Player.prefab.meta
  39. 0
      /Assets/Objects/UI/prefabs/InGame/Race_Canvas.prefab.meta
  40. 0
      /Assets/Objects/UI/prefabs/InGame/Race_Canvas_touch.prefab.meta
  41. 0
      /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Laps.prefab
  42. 0
      /Assets/Objects/UI/prefabs/InGame/Race_Canvas.prefab
  43. 0
      /Assets/Objects/UI/prefabs/InGame/Race_Canvas_touch.prefab

40
Assets/Scripts/GameSystem/AppSettings.cs


using System;
using System.Collections;
using System.Linq;
using GameplayIngredients;
using UnityEngine;
using UnityEngine.AddressableAssets;

private void OnEnable()
{
Initialize();
CmdArgs();
RenderPipelineManager.beginCameraRendering += SetRenderScale;
SceneManager.sceneLoaded += LevelWasLoaded;
}

res = 2560f;
break;
default:
res = cam.pixelWidth;
res = Screen.currentResolution.width;
var renderScale = Mathf.Clamp(res / cam.pixelWidth, 0.1f, 1.0f);
var renderScale = Mathf.Clamp(res / Screen.currentResolution.width, 0.1f, 1.0f);
maxScale = renderScale;
#if !UNITY_EDITOR
UniversalRenderPipeline.asset.renderScale = renderScale;

private void Update()
{
if (!MainCamera) return;
if (variableResolution)
{

{
UniversalRenderPipeline.asset.useSRPBatcher = enabled;
}
public static void LoadScene(int buildIndex, LoadSceneMode mode = LoadSceneMode.Single)
{
Application.backgroundLoadingPriority = ThreadPriority.Low;

DontDestroyOnLoad(Instance.loadingScreenObject);
if(Debug.isDebugBuild)
Debug.Log($"loading scene {SceneUtility.GetScenePathByBuildIndex(scene)} at build index {scene}");
// clean up
var clean = Resources.UnloadUnusedAssets();
while (!clean.isDone) { yield return null; }

#else
Application.Quit();
#endif
}
private static void CmdArgs()
{
var args = Environment.GetCommandLineArgs();
if (args.Length <= 0) return;
foreach (var argRaw in args)
{
if (argRaw[0] != '-') continue;
var arg = argRaw.Split(':');
switch (arg[0])
{
case "-loadlevel":
LoadScene(arg[1]);
break;
case "-benchmarkFlythrough":
LoadScene("benchmark_island-flythrough");
break;
}
}
}
}

108
Assets/Scripts/System/Benchmark.cs


using System;
using System.Collections.Generic;
using UnityEngine.AddressableAssets;
using System.Collections;
#endif
namespace BoatAttack

public Object[] scenes;
public List<BenchmarkSettings> settings = new List<BenchmarkSettings>();
private static BenchmarkSettings _settings;
private static bool _exitOnCompletion;
public string scene;
//public AssetReference perfStatsUI;
//public AssetReference perfSummaryUI;
#if UNITY_EDITOR
#endif
SceneManager.sceneLoaded += OnSceneLoaded;
LoadBenchmark(scene, 4, true, true);
LoadBenchmark(settings[0]);
public static void LoadBenchmark(string scene, int runs, bool perfstats, bool quitOnFinish)
private void LoadBenchmark(BenchmarkSettings setting)
_exitOnCompletion = quitOnFinish;
AppSettings.LoadScene(scene);
settings.RemoveAt(0);
_settings = setting;
AppSettings.LoadScene(setting.scene);
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (scene.name == _settings.scene)
{
switch (_settings.type)
{
case BenchmarkType.Track:
SetupFlyThroughBenchmark();
break;
case BenchmarkType.Static:
SetupStaticBenchmark();
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
private void SetupFlyThroughBenchmark()
{
var go = GameObject.FindGameObjectWithTag("benchmark_flythrough");
}
private void SetupStaticBenchmark()
{
var go = GameObject.FindGameObjectWithTag("benchmark_static");
if (_exitOnCompletion)
if (_settings.exitOnCompletion)
#endif
public class BenchmarkTool
{
static BenchmarkTool()

#if UNITY_EDITOR
//EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
var go = new GameObject("BenchmarkManager");
var bench = go.AddComponent<Benchmark>();
bench.scene = "benchmark_island-flythrough";
var settings = new BenchmarkSettings("benchmark_island-flythrough",
4,
true,
true,
true,
BenchmarkType.Track);
CreateBenchmark(settings);
}
private static void Cleanup(PlayModeStateChange state)

Object.DestroyImmediate(go);
}
}
}
public static void CreateBenchmark(BenchmarkSettings settings)
{
var go = new GameObject("BenchmarkManager");
var bench = go.AddComponent<Benchmark>();
bench.settings.Add(settings);
}
}
[Serializable]
public class PerfBasic

Os = SystemInfo.operatingSystem.Replace(" ", "");
Quality = QualitySettings.names[QualitySettings.GetQualityLevel()].Replace(" ", "");
Resolution = $"{Display.main.renderingWidth}x{Display.main.renderingHeight}";
}
}
[Serializable]
public enum BenchmarkType
{
Track,
Static
}
[Serializable]
public class BenchmarkSettings
{
public string scene = "benchmark_island-flythrough";
public int runs = 4;
public bool exitOnCompletion = true;
public bool warmup = true;
public bool stats = false;
public BenchmarkType type;
public BenchmarkSettings(string scene, int runs, bool exitOnCompletion, bool warmup, bool stats, BenchmarkType type)
{
this.scene = scene;
this.runs = runs;
this.exitOnCompletion = exitOnCompletion;
this.warmup = warmup;
this.stats = stats;
this.type = type;
}
}
}

131
Assets/scenes/Testing/benchmark_island-flythrough.unity


- component: {fileID: 359309056}
- component: {fileID: 359309055}
- component: {fileID: 359309054}
- component: {fileID: 359309053}
m_Name: Canvas
m_Name: BenchMarkCanvas
--- !u!114 &359309053
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 359309052}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b99026fb20fae4573aac6cb1c44371ea, type: 3}
m_Name:
m_EditorClassIdentifier:
runCount: 4
runLength: 1000
frametimeDisplay: {fileID: 1616875141}
--- !u!114 &359309054
MonoBehaviour:
m_ObjectHideFlags: 0

m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!223 &359309056
Canvas:
m_ObjectHideFlags: 0

- {fileID: 1658580747}
- {fileID: 90223537}
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}

propertyPath: m_Materials.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6589000190219289651, guid: e70416e3bc35d4004a9981d0ac102ba5,
type: 3}
propertyPath: m_LocalRotation.y
value: -0.33798864
objectReference: {fileID: 0}
- target: {fileID: 6589000190219289651, guid: e70416e3bc35d4004a9981d0ac102ba5,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.9290832
objectReference: {fileID: 0}
- target: {fileID: 6589000190355498174, guid: e70416e3bc35d4004a9981d0ac102ba5,
type: 3}
propertyPath: m_Materials.Array.size

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_Children:
- {fileID: 1725543952}
m_RootOrder: 3
m_RootOrder: 2
--- !u!84 &1420008408
RenderTexture:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: WaterDepthMap
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_IsAlphaChannelOptional: 0
serializedVersion: 3
m_Width: 1024
m_Height: 1024
m_AntiAliasing: 1
m_MipCount: -1
m_DepthFormat: 2
m_ColorFormat: 142
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_BindMS: 0
m_EnableCompatibleFormat: 1
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
--- !u!1 &1461309627
GameObject:
m_ObjectHideFlags: 0

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1658580747
RectTransform:
m_ObjectHideFlags: 0

- component: {fileID: 1725543952}
- component: {fileID: 1725543951}
- component: {fileID: 1725543953}
- component: {fileID: 1725543954}
m_TagString: Untagged
m_TagString: benchmark_flythrough
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 827033904}
m_Father: {fileID: 0}
m_RootOrder: 2
m_Father: {fileID: 1259603554}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1725543953
MonoBehaviour:

m_EditorClassIdentifier:
cam: {fileID: 1725543951}
frameLength: 1000
--- !u!114 &1725543954
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1725543950}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b99026fb20fae4573aac6cb1c44371ea, type: 3}
m_Name:
m_EditorClassIdentifier:
runCount: 4
runLength: 1000
frametimeDisplay: {fileID: 1616875141}
--- !u!84 &2014986599
RenderTexture:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: WaterDepthMap
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 1024
m_Height: 1024
m_AntiAliasing: 1
m_MipCount: -1
m_DepthFormat: 2
m_ColorFormat: 142
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_BindMS: 0
m_EnableCompatibleFormat: 1
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1

5
Packages/manifest.json


"com.unity.inputsystem": "1.0.0",
"com.unity.mathematics": "1.1.0",
"com.unity.memoryprofiler": "0.2.4-preview.1",
"com.unity.render-pipelines.universal": "9.0.0-preview.35",
"com.unity.render-pipelines.universal": "9.0.0-preview.47",
"com.unity.textmeshpro": "3.0.0-preview.14",
"com.unity.timeline": "1.3.4",
"com.unity.ugui": "1.0.0",

"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
}
},
"registry": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates"
}

8
Assets/Objects/UI/prefabs/InGame.meta


fileFormatVersion: 2
guid: 07b86511fd6e94a8aa9afccd5c767166
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Objects/UI/prefabs/MainMenu.meta


fileFormatVersion: 2
guid: a920ed71b5c5a4cae8b22028ac9e588a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Objects/UI/prefabs/Utility.meta


fileFormatVersion: 2
guid: 59f64f245c320443c872ce85f437dd84
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

/Assets/Objects/UI/prefabs/BaseButton.prefab → /Assets/Objects/UI/prefabs/Utility/BaseButton.prefab

/Assets/Objects/UI/prefabs/BaseButton.prefab.meta → /Assets/Objects/UI/prefabs/Utility/BaseButton.prefab.meta

/Assets/Objects/UI/prefabs/BaseButton_Back.prefab → /Assets/Objects/UI/prefabs/Utility/BaseButton_Back.prefab

/Assets/Objects/UI/prefabs/BaseButton_Back.prefab.meta → /Assets/Objects/UI/prefabs/Utility/BaseButton_Back.prefab.meta

/Assets/Objects/UI/prefabs/BaseButton_Finish.prefab → /Assets/Objects/UI/prefabs/Utility/BaseButton_Finish.prefab

/Assets/Objects/UI/prefabs/BaseButton_Finish.prefab.meta → /Assets/Objects/UI/prefabs/Utility/BaseButton_Finish.prefab.meta

/Assets/Objects/UI/prefabs/BaseButton_Next.prefab → /Assets/Objects/UI/prefabs/Utility/BaseButton_Next.prefab

/Assets/Objects/UI/prefabs/BaseButton_Next.prefab.meta → /Assets/Objects/UI/prefabs/Utility/BaseButton_Next.prefab.meta

/Assets/Objects/UI/prefabs/BaseButton_Race.prefab → /Assets/Objects/UI/prefabs/Utility/BaseButton_Race.prefab

/Assets/Objects/UI/prefabs/BaseButton_Race.prefab.meta → /Assets/Objects/UI/prefabs/Utility/BaseButton_Race.prefab.meta

/Assets/Objects/UI/prefabs/BaseButton_Rematch.prefab → /Assets/Objects/UI/prefabs/Utility/BaseButton_Rematch.prefab

/Assets/Objects/UI/prefabs/BaseButton_Rematch.prefab.meta → /Assets/Objects/UI/prefabs/Utility/BaseButton_Rematch.prefab.meta

/Assets/Objects/UI/prefabs/BoatRoom.prefab → /Assets/Objects/UI/prefabs/MainMenu/BoatRoom.prefab

/Assets/Objects/UI/prefabs/BoatRoom.prefab.meta → /Assets/Objects/UI/prefabs/MainMenu/BoatRoom.prefab.meta

/Assets/Objects/UI/prefabs/MainMenuUI.prefab → /Assets/Objects/UI/prefabs/MainMenu/MainMenuUI.prefab

/Assets/Objects/UI/prefabs/MainMenuUI.prefab.meta → /Assets/Objects/UI/prefabs/MainMenu/MainMenuUI.prefab.meta

/Assets/Objects/UI/prefabs/MenuOption.prefab → /Assets/Objects/UI/prefabs/MainMenu/MenuOption.prefab

/Assets/Objects/UI/prefabs/MenuOption.prefab.meta → /Assets/Objects/UI/prefabs/MainMenu/MenuOption.prefab.meta

/Assets/Objects/UI/prefabs/MenuOption_BoatType.prefab → /Assets/Objects/UI/prefabs/MainMenu/MenuOption_BoatType.prefab

/Assets/Objects/UI/prefabs/MenuOption_BoatType.prefab.meta → /Assets/Objects/UI/prefabs/MainMenu/MenuOption_BoatType.prefab.meta

/Assets/Objects/UI/prefabs/MenuOption_Laps.prefab.meta → /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Laps.prefab.meta

/Assets/Objects/UI/prefabs/MenuOption_Level.prefab → /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Level.prefab

/Assets/Objects/UI/prefabs/MenuOption_Level.prefab.meta → /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Level.prefab.meta

/Assets/Objects/UI/prefabs/MenuOption_Reverse.prefab → /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Reverse.prefab

/Assets/Objects/UI/prefabs/MenuOption_Reverse.prefab.meta → /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Reverse.prefab.meta

/Assets/Objects/UI/prefabs/PlayerMapMarker.prefab → /Assets/Objects/UI/prefabs/InGame/PlayerMapMarker.prefab

/Assets/Objects/UI/prefabs/PlayerMapMarker.prefab.meta → /Assets/Objects/UI/prefabs/InGame/PlayerMapMarker.prefab.meta

/Assets/Objects/UI/prefabs/PlayerMarker.prefab → /Assets/Objects/UI/prefabs/InGame/PlayerMarker.prefab

/Assets/Objects/UI/prefabs/PlayerMarker.prefab.meta → /Assets/Objects/UI/prefabs/InGame/PlayerMarker.prefab.meta

/Assets/Objects/UI/prefabs/RaceStats_Player.prefab → /Assets/Objects/UI/prefabs/InGame/RaceStats_Player.prefab

/Assets/Objects/UI/prefabs/RaceStats_Player.prefab.meta → /Assets/Objects/UI/prefabs/InGame/RaceStats_Player.prefab.meta

/Assets/Objects/UI/prefabs/Race_Canvas.prefab.meta → /Assets/Objects/UI/prefabs/InGame/Race_Canvas.prefab.meta

/Assets/Objects/UI/prefabs/Race_Canvas_touch.prefab.meta → /Assets/Objects/UI/prefabs/InGame/Race_Canvas_touch.prefab.meta

/Assets/Objects/UI/prefabs/MenuOption_Laps.prefab → /Assets/Objects/UI/prefabs/MainMenu/MenuOption_Laps.prefab

/Assets/Objects/UI/prefabs/Race_Canvas.prefab → /Assets/Objects/UI/prefabs/InGame/Race_Canvas.prefab

/Assets/Objects/UI/prefabs/Race_Canvas_touch.prefab → /Assets/Objects/UI/prefabs/InGame/Race_Canvas_touch.prefab

正在加载...
取消
保存