Extending & Customizing¶
On this page
The package is built to be extended — everything below is the same pattern the built-in features use.
Add your own feature manager¶
// 1. Config block (nested in PlayFabHubSettings or your own SO)
[Serializable] public class QuestConfig { public bool enabled = true; /* knobs */ }
// 2. Manager — plain C#, inherits the shared base
public sealed class QuestManager : PlayFabFeature
{
public override string FeatureName => "Quests";
public override bool IsEnabled => /* your toggle */ true;
public void GetQuests(Action<HubResult<MyQuests>> done)
{
if (!IsLoggedIn) { done?.Invoke(NotLoggedIn<MyQuests>()); return; }
// Net = retry/backoff-wrapped executor; collapses callbacks into HubResult
PlayFabHub.CloudScript.Execute<MyQuests>("getQuests", null, done);
}
}
// 3. Register at init (or call PlayFabHub.Register<QuestManager>(new ...))
Add prerequisites for your feature¶
Append descriptors to PrerequisiteRegistry.External from any editor script —
they appear automatically on BOTH the Setup page and the Health Check:
[InitializeOnLoad]
static class QuestPrereqs
{
static QuestPrereqs() => PrerequisiteRegistry.External.Add(new FeaturePrerequisite
{
id = "quests.handler", feature = "Quests", kind = PrereqKind.LivePlayFab,
title = "getQuests handler deployed", liveProbeId = "cloudscript.handlers",
docUrl = "https://learn.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript/",
});
}
Listen to results — three tiers¶
- Per call: every manager method takes a callback receiving
HubResult<T>. - Global C# events:
PlayFabHubEvents.OnLoginStateChanged / OnInventoryChanged / OnError / …— for systems that react regardless of who made the call. - Inspector UnityEvents: drop the Samples'
PlayFabHubEventBridgeon a GameObject and wire events visually (copy + extend it freely).
Bring your own UI¶
Managers are 100% UI-agnostic. The six sample controllers (uGUI & UI Toolkit)
are intentionally ~100 lines each — copy the one matching your UI stack and
re-skin. Nothing in Runtime/ references any UI type.
Author your economy in Unity — ICatalogSource¶
The Admin Hub's Catalog Pusher and Economy Validator never hardcode your
item list. They discover an ICatalogSource implementation in your project via
TypeCache — implement it in any Editor assembly (an Editor/ folder works)
and the pusher/validator pick it up automatically:
using System;
using System.Collections.Generic;
using MoDev.Editor.PlayFabAdmin;
public class MyCatalogSource : ICatalogSource
{
public string Name => "MyGame ScriptableObject catalog";
public IReadOnlyList<CatalogItemDraft> GetItems(Action<string> log, out string countSummary)
{
var items = new List<CatalogItemDraft>();
// Build drafts from your own authoring assets (ScriptableObjects, CSV, …)
items.Add(new CatalogItemDraft
{
ItemId = "sword_01",
ItemClass = "shop_item",
DisplayName = "Iron Sword",
});
countSummary = $"shop {items.Count}";
return items;
}
}
Keep the implementation project-side — it describes your game's economy and is exactly the seam that stays out of the package.
Server logic without Azure¶
Put gameplay-critical grants and validated score writes in Legacy CloudScript JS or another trusted backend. Deploy Legacy JavaScript from the Admin Hub. The built-in Google/Apple receipt helpers instead call PlayFab legacy Client validation APIs; no custom CloudScript is needed for them. See feature setup. The package ships a read-only hubGetServerTime example in ServerExamples~/hubGetServerTime.js.txt.
Copy it to your configured CloudScript folder and remove the .txt suffix before deployment.
Grants, offers, moderation policies, and platform receipt backends belong to your title and are not bundled.
See Server integration for the optional UGC adapter contract.