Skip to content

Commit 56d638b

Browse files
authored
QualityTuner: minimum implementation (#21)
* PerformanceIndex: minimum implementation * fixed review points * PerformanceIndex: split GPU series to major and minor * PerformanceIndex: able to switch performance level using hardware stats * PerformanceIndex: addred README and refactoring * fixed review points * PerformanceIndex: Split data by platform * PerformanceIndex: cleanup code * PermanceIndex: add tooltip * PerformanceIndex: Combined enum selection for selecting table * PerformanceIndex: Combined series number range * PerformanceIndex: added more docs * PerformanceIndex: refactoring * fixed for review points * renamce package name * revised docs * rename again and some refactoring * fix docs * fixed review points * rename Match to TryMatch * fixed remained old names
1 parent c92c13b commit 56d638b

58 files changed

Lines changed: 2085 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/Scenes/SampleScene.unity

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ Transform:
202202
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
203203
m_LocalPosition: {x: 0, y: 0, z: -10}
204204
m_LocalScale: {x: 1, y: 1, z: 1}
205+
m_ConstrainProportionsScale: 0
205206
m_Children: []
206207
m_Father: {fileID: 0}
207208
m_RootOrder: 0
@@ -245,6 +246,7 @@ Transform:
245246
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
246247
m_LocalPosition: {x: 0, y: 0, z: 0}
247248
m_LocalScale: {x: 1, y: 1, z: 1}
249+
m_ConstrainProportionsScale: 0
248250
m_Children: []
249251
m_Father: {fileID: 0}
250252
m_RootOrder: 2
@@ -288,6 +290,7 @@ Transform:
288290
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
289291
m_LocalPosition: {x: 2.28049, y: -1.0345491, z: -0.6233101}
290292
m_LocalScale: {x: 1, y: 1, z: 1}
293+
m_ConstrainProportionsScale: 0
291294
m_Children: []
292295
m_Father: {fileID: 0}
293296
m_RootOrder: 3
@@ -331,7 +334,53 @@ Transform:
331334
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
332335
m_LocalPosition: {x: 0, y: 0, z: 0}
333336
m_LocalScale: {x: 1, y: 1, z: 1}
337+
m_ConstrainProportionsScale: 0
334338
m_Children: []
335339
m_Father: {fileID: 0}
336340
m_RootOrder: 1
337341
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
342+
--- !u!1 &2110764687
343+
GameObject:
344+
m_ObjectHideFlags: 0
345+
m_CorrespondingSourceObject: {fileID: 0}
346+
m_PrefabInstance: {fileID: 0}
347+
m_PrefabAsset: {fileID: 0}
348+
serializedVersion: 6
349+
m_Component:
350+
- component: {fileID: 2110764689}
351+
- component: {fileID: 2110764688}
352+
m_Layer: 0
353+
m_Name: QualityMapper
354+
m_TagString: Untagged
355+
m_Icon: {fileID: 0}
356+
m_NavMeshLayer: 0
357+
m_StaticEditorFlags: 0
358+
m_IsActive: 1
359+
--- !u!114 &2110764688
360+
MonoBehaviour:
361+
m_ObjectHideFlags: 0
362+
m_CorrespondingSourceObject: {fileID: 0}
363+
m_PrefabInstance: {fileID: 0}
364+
m_PrefabAsset: {fileID: 0}
365+
m_GameObject: {fileID: 2110764687}
366+
m_Enabled: 1
367+
m_EditorHideFlags: 0
368+
m_Script: {fileID: 11500000, guid: 5bf0ba71edb654df5b218fdc2b883fd6, type: 3}
369+
m_Name:
370+
m_EditorClassIdentifier:
371+
sampleQualityLevelRuleData: {fileID: 11400000, guid: 6e2a7cbd15c2741478cb75a873a45f53, type: 2}
372+
--- !u!4 &2110764689
373+
Transform:
374+
m_ObjectHideFlags: 0
375+
m_CorrespondingSourceObject: {fileID: 0}
376+
m_PrefabInstance: {fileID: 0}
377+
m_PrefabAsset: {fileID: 0}
378+
m_GameObject: {fileID: 2110764687}
379+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
380+
m_LocalPosition: {x: 0.32165855, y: -1.1358906, z: 0.019236887}
381+
m_LocalScale: {x: 1, y: 1, z: 1}
382+
m_ConstrainProportionsScale: 0
383+
m_Children: []
384+
m_Father: {fileID: 0}
385+
m_RootOrder: 4
386+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

Assets/Scripts/QualityTunerView.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// --------------------------------------------------------------
2+
// Copyright 2023 CyberAgent, Inc.
3+
// --------------------------------------------------------------
4+
5+
using System.Text;
6+
using MobileSupport.QualityTuner;
7+
using UnityEngine;
8+
9+
public class QualityTunerView : MonoBehaviour
10+
{
11+
[SerializeField]
12+
private SampleQualityRuleData sampleQualityRuleData;
13+
14+
private void Start()
15+
{
16+
var stats = HardwareInfo.GetHardwareStats();
17+
var sb = new StringBuilder();
18+
sb.AppendLine($"DeviceModel: {stats.DeviceModel}");
19+
sb.AppendLine($"GpuName: {stats.GpuName}");
20+
sb.AppendLine($"GpuMajorSeries: {stats.GpuMajorSeries}");
21+
sb.AppendLine($"GpuMinorSeries: {stats.GpuMinorSeries}");
22+
sb.AppendLine($"GpuSeriesNumber: {stats.GpuSeriesNumber}");
23+
sb.AppendLine($"SocName: {stats.SocName}");
24+
sb.AppendLine($"GpuMemorySizeMb: {stats.GpuMemorySizeMb}");
25+
sb.AppendLine($"SystemMemorySizeMb: {stats.SystemMemorySizeMb}");
26+
Debug.Log(sb.ToString());
27+
28+
if (sampleQualityRuleData == null)
29+
{
30+
Debug.LogError("SampleQualityLevelSelector is null");
31+
}
32+
else
33+
{
34+
var sampleQualityLevelSelector = new RuleBasedQualitySelector<SampleQualityLevel>(sampleQualityRuleData);
35+
// you can add new rule matcher at runtime, like deserializing from json
36+
var newMatcher =
37+
JsonUtility.FromJson<SampleDeviceNameRuleMatcher>(
38+
@"{""rules"":[{""deviceModel"":""MacBookPro18,2"",""qualityLevel"":2}]}");
39+
sampleQualityLevelSelector.QualityLevelRuleMatchers.Add(newMatcher);
40+
if (sampleQualityLevelSelector.TryGetQualityLevel(stats, out var qualityLevel))
41+
Debug.Log($"QualityLevel: {qualityLevel}");
42+
else
43+
Debug.Log("QualityLevel: Unknown");
44+
}
45+
}
46+
}

Assets/Scripts/QualityTunerView.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: bbdbc7b9b2a5e46ab9f0091774f6e7bb, type: 3}
13+
m_Name: SampleQualityRuleData
14+
m_EditorClassIdentifier:
15+
defaultQualityLevel: 1
16+
qualityLevelRuleMatchers:
17+
- rid: 7788121862593052687
18+
- rid: 7788121862593052688
19+
- rid: 7788121862593052689
20+
references:
21+
version: 2
22+
RefIds:
23+
- rid: 7788121862593052687
24+
type: {class: SampleDeviceNameRuleMatcher, ns: , asm: Assembly-CSharp}
25+
data:
26+
rules:
27+
- deviceModel: MacBookPro18,2
28+
qualityLevel: 2
29+
- rid: 7788121862593052688
30+
type: {class: SampleGpuSeriesRuleMatcher, ns: , asm: Assembly-CSharp}
31+
data:
32+
rules:
33+
- gpuSeries:
34+
value: 12
35+
gpuMajorSeries: 1
36+
gpuMinorSeries: 12
37+
gpuSeriesNumberMin: 0
38+
gpuSeriesNumberMax: 9999
39+
qualityLevel: 2
40+
- gpuSeries:
41+
value: 11
42+
gpuMajorSeries: 1
43+
gpuMinorSeries: 11
44+
gpuSeriesNumberMin: 0
45+
gpuSeriesNumberMax: 10
46+
qualityLevel: 1
47+
- gpuSeries:
48+
value: 11
49+
gpuMajorSeries: 1
50+
gpuMinorSeries: 11
51+
gpuSeriesNumberMin: 11
52+
gpuSeriesNumberMax: 99
53+
qualityLevel: 2
54+
- gpuSeries:
55+
value: 20
56+
gpuMajorSeries: 2
57+
gpuMinorSeries: 0
58+
gpuSeriesNumberMin: 0
59+
gpuSeriesNumberMax: 540
60+
qualityLevel: 0
61+
- gpuSeries:
62+
value: 20
63+
gpuMajorSeries: 2
64+
gpuMinorSeries: 0
65+
gpuSeriesNumberMin: 541
66+
gpuSeriesNumberMax: 629
67+
qualityLevel: 1
68+
- gpuSeries:
69+
value: 20
70+
gpuMajorSeries: 2
71+
gpuMinorSeries: 0
72+
gpuSeriesNumberMin: 630
73+
gpuSeriesNumberMax: 999
74+
qualityLevel: 2
75+
- rid: 7788121862593052689
76+
type: {class: SampleSystemMemoryRuleMatcher, ns: , asm: Assembly-CSharp}
77+
data:
78+
rules:
79+
- systemMemoryMin: 0
80+
systemMemoryMax: 2048
81+
qualityLevel: 0
82+
- systemMemoryMin: 2049
83+
systemMemoryMax: 4096
84+
qualityLevel: 1
85+
- systemMemoryMin: 4097
86+
systemMemoryMax: 99999
87+
qualityLevel: 2

Assets/Scripts/SampleQualityRuleData.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// --------------------------------------------------------------
2+
// Copyright 2023 CyberAgent, Inc.
3+
// --------------------------------------------------------------
4+
5+
using MobileSupport.QualityTuner;
6+
using UnityEngine;
7+
8+
[CreateAssetMenu(fileName = nameof(SampleQualityRuleData), menuName = "Sample/Quality Level Rule Data")]
9+
public class SampleQualityRuleData : QualityRuleData<SampleQualityLevel>
10+
{
11+
}
12+
13+
public class SampleDeviceNameRuleMatcher : DeviceNameRuleMatcherBase<SampleQualityLevel>
14+
{
15+
}
16+
17+
public class SampleGpuSeriesRuleMatcher : GpuSeriesRuleMatcherBase<SampleQualityLevel, GpuSeriesEnumeration>
18+
{
19+
}
20+
21+
public class SampleSystemMemoryRuleMatcher : SystemMemoryRuleMatcherBase<SampleQualityLevel>
22+
{
23+
}
24+
25+
public enum SampleQualityLevel
26+
{
27+
Low,
28+
Medium,
29+
High
30+
}

Assets/Scripts/SampleQualityRuleData.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
using System.Runtime.CompilerServices;
22

3-
[assembly: InternalsVisibleTo("MobileSupport.AndroidGame.EditorTests")]
3+
[assembly: InternalsVisibleTo("MobileSupport.AndroidGame.Editor.Tests")]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Release notes
2+
3+
## v1.0.0 - 2024-01-04
4+
5+
- New Features :rocket:
6+
- Function to get hardware stats to identify performance index of device

Packages/MobileSupportQualityTuner/CHANGELOG.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)