Skip to content

Commit

Permalink
* Add new Integration Steps tab in Editor settings
Browse files Browse the repository at this point in the history
* LoadingState in Annotation message is obsolete
  • Loading branch information
ktaraymovich committed May 26, 2021
1 parent 2da20a0 commit 1d56b84
Show file tree
Hide file tree
Showing 16 changed files with 297 additions and 128 deletions.
27 changes: 18 additions & 9 deletions Editor/Scripts/AndroidPerformanceTunerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static void OpenGithub()

SettingsEditor m_SettingsEditor;
FidelityParametersEditor m_FidelityParametersEditor;
IntegrationStepsEditor m_IntegrationStepsEditor;
AnnotationMessageEditor m_AnnotationMessageEditor;
FidelityMessageEditor m_FidelityMessageEditor;
InstrumentationSettingsEditor m_InstrumentationSettingsEditor;
Expand All @@ -79,36 +80,41 @@ protected void OnEnable()
m_SetupConfig = FileUtil.LoadSetupConfig();

m_SettingsEditor = new SettingsEditor(Initializer.projectData, m_SetupConfig);
m_IntegrationStepsEditor = new IntegrationStepsEditor(Initializer.projectData, m_SetupConfig);
m_FidelityParametersEditor =
new FidelityParametersEditor(Initializer.projectData, Initializer.devDescriptor);
m_AnnotationMessageEditor = new AnnotationMessageEditor(m_SetupConfig, Initializer.protoFile,
Initializer.devDescriptor.annotationMessage, Initializer.enumInfoHelper);
m_AnnotationMessageEditor = new AnnotationMessageEditor(Initializer.projectData, m_SetupConfig,
Initializer.protoFile, Initializer.devDescriptor.annotationMessage, Initializer.enumInfoHelper);
m_FidelityMessageEditor = new FidelityMessageEditor(Initializer.projectData, m_SetupConfig,
Initializer.protoFile,
Initializer.devDescriptor.fidelityMessage, Initializer.enumInfoHelper);
m_InstrumentationSettingsEditor =
new InstrumentationSettingsEditor(Initializer.projectData);
}

readonly string[] m_ToolbarOptions = new string[5]
const int MenuSize = 6;

readonly string[] m_ToolbarOptions = new string[MenuSize]
{
"Settings",
"Integration Checklist",
"Annotation parameters",
"Fidelity parameters",
"Quality levels",
"Instrumentation Settings"
};

readonly string[] m_Tooltips = new string[5]
readonly string[] m_Tooltips = new string[MenuSize]
{
null,
null,
null,
null,
"To create custom quality levels, use custom fidelity parameters.",
null
};

readonly bool[] m_ToolbarEnabled = new bool[5] {true, true, true, true, true};
readonly bool[] m_ToolbarEnabled = new bool[MenuSize] {true, true, true, true, true, true};
int m_ToolbarSelected = 0;

//TODO(b/120588304) Check if that color is ok.
Expand All @@ -131,7 +137,7 @@ void OnGUI()
return;
}

m_ToolbarEnabled[3] = m_SetupConfig.useAdvancedFidelityParameters;
m_ToolbarEnabled[4] = m_SetupConfig.useAdvancedFidelityParameters;
DrawMenu();
using (new GUILayout.HorizontalScope())
{
Expand All @@ -148,15 +154,18 @@ void OnGUI()
m_SettingsEditor.OnGUI();
break;
case 1:
m_AnnotationMessageEditor.OnGUI();
m_IntegrationStepsEditor.OnGUI();
break;
case 2:
m_FidelityMessageEditor.OnGUI();
m_AnnotationMessageEditor.OnGUI();
break;
case 3:
m_FidelityParametersEditor.OnGUI();
m_FidelityMessageEditor.OnGUI();
break;
case 4:
m_FidelityParametersEditor.OnGUI();
break;
case 5:
m_InstrumentationSettingsEditor.OnGUI();
break;
}
Expand Down
30 changes: 23 additions & 7 deletions Editor/Scripts/AnnotationMessageEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public class AnnotationMessageEditor : MessageEditor
"This parameter is recognized as a scene parameter. " +
"If your game is not using / not matching unity scene system, you can remove it from your annotation.";

const string k_LoadingInfo =
"This parameter is recognized as a loading parameter. " +
"Loading annotations mark frames that are part of the level loading process. " +
"It is highly recommended that you use loading annotations so that slower frames " +
"while the game is loading do not affect your overall metrics.";

readonly GUIContent m_SceneFieldInfo;

Expand All @@ -58,8 +53,10 @@ protected override string[] headers
get { return m_Headers; }
}

public AnnotationMessageEditor(SetupConfig config, FileInfo protoFile, MessageDescriptor descriptor,
public AnnotationMessageEditor(ProjectData projectData, SetupConfig config, FileInfo protoFile,
MessageDescriptor descriptor,
EnumInfoHelper enumInfoHelper) : base(
projectData,
config,
descriptor,
ProtoMessageType.Annotation,
Expand All @@ -68,8 +65,27 @@ public AnnotationMessageEditor(SetupConfig config, FileInfo protoFile, MessageDe
enumInfoHelper)
{
var icon = (Texture) Resources.Load("baseline_info_outline");
var error = (Texture) Resources.Load("ic_error_outline");
m_SceneFieldInfo = new GUIContent(icon, k_SceneInfo);
m_LoadingFieldInfo = new GUIContent(icon, k_LoadingInfo);
m_LoadingFieldInfo = new GUIContent(error, Names.removeLoadingStateTooltip);
}

public override void OnGUI()
{
if (!m_Config.useAdvancedAnnotations && m_ProjectData.hasLoadingState)
{
GUILayout.Space(15);
GUILayout.BeginHorizontal();
EditorGUILayout.HelpBox(Names.fixDefaultAnnotationMessage, MessageType.Error);
if (GUILayout.Button("Fix"))
{
SaveState();
}

GUILayout.EndHorizontal();
}

base.OnGUI();
}

protected override FieldInfo RenderInfo(FieldInfo info, Rect rect, int index)
Expand Down
42 changes: 10 additions & 32 deletions Editor/Scripts/DefaultMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,23 @@ public class DefaultMessages
* Default proto:
* syntax = "proto3";
* option csharp_namespace = "Google.Android.PerformanceTuner";
* enum LoadingState {
* LOADINGSTATE_INVALID = 0;
* LOADINGSTATE_NOT_LOADING = 1;
* LOADINGSTATE_LOADING = 2;
* }
* enum Scene {
* SCENE_INVALID = 0;
* }
* message Annotation {
* LoadingState loading_state = 1;
* Scene scene = 2;
* Scene scene = 1;
* }
* message FidelityParams {
* int32 level = 1;
* }
*/

public static readonly ByteString serializedDefaultProto = ByteString.FromBase64(string.Concat(
"ChRkZXZfdHVuaW5nZm9yay5wcm90byJJCgpBbm5vdGF0aW9uEiQKDWxvYWRp",
"bmdfc3RhdGUYASABKA4yDS5Mb2FkaW5nU3RhdGUSFQoFc2NlbmUYAiABKA4y",
"Bi5TY2VuZSIfCg5GaWRlbGl0eVBhcmFtcxINCgVsZXZlbBgBIAEoBSpgCgxM",
"b2FkaW5nU3RhdGUSGAoUTE9BRElOR1NUQVRFX0lOVkFMSUQQABIcChhMT0FE",
"SU5HU1RBVEVfTk9UX0xPQURJTkcQARIYChRMT0FESU5HU1RBVEVfTE9BRElO",
"RxACKksKBVNjZW5lEhEKDVNDRU5FX0lOVkFMSUQQABIvCitTQ0VORV9BU1NF",
"VFNfUFJJVkFURV9SVU5USU1FX1NDRU5FU19ERUZBVUxUEAFCIqoCH0dvb2ds",
"ZS5BbmRyb2lkLlBlcmZvcm1hbmNlVHVuZXJiBnByb3RvMw=="));

public static EnumInfo loadingStateEnum = new EnumInfo
{
name = Names.loadingStateEnumName,
values = new List<string> {"INVALID", "NOT_LOADING", "LOADING"}
};
"ChRkZXZfdHVuaW5nZm9yay5wcm90byIjCgpBbm5vdGF0aW9uEhUKBXNjZW5l",
"GAEgASgOMgYuU2NlbmUiHwoORmlkZWxpdHlQYXJhbXMSDQoFbGV2ZWwYASAB",
"KAUqGgoFU2NlbmUSEQoNU0NFTkVfSU5WQUxJRBAAQiKqAh9Hb29nbGUuQW5k",
"cm9pZC5QZXJmb3JtYW5jZVR1bmVyYgZwcm90bzM="));

static readonly FieldInfo k_LoadingStateField = new FieldInfo()
{
name = Names.loadingStateFieldName,
fieldType = FieldInfo.FieldType.Enum,
enumType = Names.loadingStateEnumName,
};

static readonly FieldInfo k_SceneField = new FieldInfo()
{
Expand All @@ -88,7 +66,7 @@ public class DefaultMessages
public static readonly MessageInfo annotationMessage = new MessageInfo
{
name = "Annotation",
fields = new List<FieldInfo> {k_LoadingStateField, k_SceneField}
fields = new List<FieldInfo> {k_SceneField}
};


Expand All @@ -107,9 +85,9 @@ public static bool IsSceneField(FieldDescriptor field)

public static bool IsLoadingStateField(FieldDescriptor field)
{
return field.Name == k_LoadingStateField.name &&
return field.Name == Names.loadingStateFieldName &&
field.FieldType == FieldType.Enum &&
field.EnumType.Name == k_LoadingStateField.enumType;
field.EnumType.Name == Names.loadingStateEnumName;
}

public static bool IsSceneField(FieldInfo field)
Expand All @@ -121,9 +99,9 @@ public static bool IsSceneField(FieldInfo field)

public static bool IsLoadingStateField(FieldInfo field)
{
return field.name == k_LoadingStateField.name &&
return field.name == Names.loadingStateFieldName &&
field.fieldType == FieldInfo.FieldType.Enum &&
field.enumType == k_LoadingStateField.enumType;
field.enumType == Names.loadingStateEnumName;
}
}
}
4 changes: 1 addition & 3 deletions Editor/Scripts/FidelityMessageEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ namespace Google.Android.PerformanceTuner.Editor
{
public class FidelityMessageEditor : MessageEditor
{
ProjectData m_ProjectData;

const string k_BasicInfo =
" Unity quality levels are used as Android Performance Tuner quality levels.\n" +
" Unity quality settings are updated automatically when they're updated from the server.";
Expand All @@ -49,14 +47,14 @@ protected override string[] headers
public FidelityMessageEditor(ProjectData projectData, SetupConfig config, FileInfo protoFile,
MessageDescriptor descriptor,
EnumInfoHelper enumInfoHelper) : base(
projectData,
config,
descriptor,
ProtoMessageType.FidelityParams,
DefaultMessages.fidelityMessage,
protoFile,
enumInfoHelper)
{
m_ProjectData = projectData;
}

protected override FieldInfo RenderInfo(FieldInfo info, Rect rect, int index)
Expand Down
12 changes: 10 additions & 2 deletions Editor/Scripts/Initializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ static Initializer()
}

UpdateFidelityMessages();
CheckForLoadingStateInAnnotation();

// TODO(kseniia): Check for possible inconsistencies in the data, set to false if any found
// TODO(kseniia): or remove "valid" if all problems could be fixed in-place
Expand All @@ -102,6 +103,14 @@ public static void RefreshAssetsCompleted()
Debug.Log("Android Performance Tuner RefreshAssetsCompleted");
}

static void CheckForLoadingStateInAnnotation()
{
if (projectData.hasLoadingState)
{
Debug.LogError(Names.fixDefaultAnnotationConsoleMessage);
}
}

static DevDescriptor CreateDescriptor()
{
if (File.Exists(Paths.devDescriptorPath))
Expand Down Expand Up @@ -129,9 +138,8 @@ static Proto.FileInfo CreateProtoFile(DevDescriptor devDescriptor)
{
var protoFile = new Proto.FileInfo(devDescriptor.fileDescriptor);

// Always add scene and loading state enum.
// Always add scene.
protoFile.AddEnum(EnumInfoHelper.GetSceneEnum(EditorBuildSettings.scenes));
protoFile.AddEnum(DefaultMessages.loadingStateEnum);

protoFile.onUpdate += () =>
{
Expand Down
Loading

0 comments on commit 1d56b84

Please sign in to comment.