public void OnPreprocessBuild(BuildReport report) { if (!DiSettings.TryGetInstance(out var settings) || !settings.BakeOnBuild) { return; } Debug.Log("Baking DI injection..."); InjectionBakingMenu.Bake(); Debug.Log("Successfully baked DI injection."); }
public override void OnInspectorGUI() { serializedObject.Update(); base.OnInspectorGUI(); var boxStyle = GUI.skin.box; boxStyle.richText = true; _stringBuilder.Clear(); if (!BakedInjection.DataExists) { _stringBuilder.Append("<color=yellow>Injection is not baked.</color>"); } else { _stringBuilder.AppendLine("<color=green>Injection is baked.</color>"); if (BakedInjection.BakedInjectionFunctionsCount == 0 && BakedInjection.BakedPocoInstantiationFunctionsCount == 0) { _stringBuilder.Append("<color=yellow>However, data is empty.</color>"); } else { _stringBuilder.Append("There is data for ") .Append(BakedInjection.BakedInjectionFunctionsCount) .Append(" component type(s) and ") .Append(BakedInjection.BakedPocoInstantiationFunctionsCount) .Append(" normal C# class(es)."); } } GUILayout.BeginHorizontal(); if (GUILayout.Button("Bake")) { EditorUtility.SetDirty(target); serializedObject.ApplyModifiedProperties(); InjectionBakingMenu.Bake(); } if (GUILayout.Button("Clear Baked Data")) { EditorUtility.SetDirty(target); serializedObject.ApplyModifiedProperties(); InjectionBakingMenu.Clear(); } GUILayout.EndHorizontal(); GUILayout.Box(_stringBuilder.ToString(), boxStyle, _expandWidth); }