All-in-One Solution for Indie Game Development · Empowering Indie Developers' Dreams
Documentation · Quick Start · QQ Group: 467608841 / 233840761
- Multi-platform support: iOS, tvOS, visionOS, Android, Editor, PC (Windows/Mac/Linux), WebGL, UWP, PS4, PS5, Xbox One, Nintendo Switch.
- Provides a simple API to retrieve predefined channel information.
- Automatically adds a default channel to
Info.plistduring iOS builds (if not already set).
Choose one of the following methods:
-
Edit your Unity project's
Packages/manifest.jsonand add thescopedRegistriessection:{ "scopedRegistries": [ { "name": "GameFrameX", "url": "https://gameframex.upm.alianblank.uk", "scopes": [ "com.gameframex" ] } ], "dependencies": { "com.gameframex.unity.getchannel": "1.3.2" } }scopescontrols which packages are resolved through this registry. Only packages whose names start withcom.gameframexwill be fetched from it. -
Add to
manifest.jsondependencies:{ "com.gameframex.unity.getchannel": "https://github.com/gameframex/com.gameframex.unity.getchannel.git" } -
Use Package Manager in Unity with Git URL:
https://github.com/gameframex/com.gameframex.unity.getchannel.git -
Clone the repository into your Unity project's
Packagesdirectory. It will be loaded automatically.
Edit your Unity project's Packages/manifest.json and add the scopedRegistries section:
{
"scopedRegistries": [
{
"name": "GameFrameX",
"url": "https://gameframex.upm.alianblank.uk",
"scopes": [
"com.gameframex"
]
}
]
}scopes controls which packages are resolved through this registry. Only packages whose names start with com.gameframex will be fetched from it.
Then add the package to dependencies:
{
"dependencies": {
"com.gameframex.unity.getchannel": "1.3.2"
}
}In your C# scripts, use the BlankGetChannel.GetChannelName(string key) method to retrieve channel information. The key parameter is the key name you used when setting up the channel information on the corresponding platform.
Example Code:
using UnityEngine;
public class MyGameScript : MonoBehaviour
{
void Start()
{
// Get default channel (key name is "channel")
string channel = BlankGetChannel.GetChannelName();
Debug.Log("Current channel: " + channel);
// Get channel with a specific key
string customChannel = BlankGetChannel.GetChannelName("channelName");
Debug.Log("Custom channel: " + customChannel);
// Get channel with a default fallback value
string subChannel = BlankGetChannel.GetChannelName("sub_channel", "unknown");
Debug.Log("Sub channel: " + subChannel);
}
}For iOS, tvOS, and visionOS platforms, the plugin includes a build post-processor (PostProcessBuildHandler.cs). When building, if the project's Info.plist file:
- Does not have a key named
channel, the script will automatically add an entry with keychanneland valuedefault. - Already has a key named
channel, no modifications will be made.
You can modify the channel value in the Xcode project's Info.plist file, or use your custom key name when calling BlankGetChannel.GetChannelName() (ensure that key name exists in Info.plist).
Info.plist Configuration Example:
<key>channel</key>
<string>ios_cn_taptap</string>
<key>sub_channel</key>
<string>beta</string>For the Android platform, you need to define channel information in the AndroidManifest.xml file. This is typically done by adding <meta-data> tags within the <application> tag.
For example, if you want to use the key name channel and value android_cn_taptap:
<application ...>
<activity ...>
...
</activity>
<meta-data
android:name="channel"
android:value="android_cn_taptap" />
<meta-data
android:name="sub_channel"
android:value="beta" />
<!-- other meta-data -->
</application>Then, you can retrieve this value in C# code using BlankGetChannel.GetChannelName("channel").
For Editor, PC (Windows/Mac/Linux), WebGL, UWP, PS4, PS5, Xbox One, Nintendo Switch, and other platforms, you need to create a text file named application_config.txt in the Resources folder of your Unity project.
application_config.txt File Format Example:
channel=editor_cn_test
sub_channel=beta
other_key=other_value
Each line format is: key=value
The plugin will automatically read the key-value pairs from this file and cache them for subsequent use.
- Ensure that the
keyyou use when callingBlankGetChannel.GetChannelName(string key)matches the key name you set in the corresponding platform's configuration file:- iOS / tvOS / visionOS:
Info.plistfile - Android:
<meta-data>tags inAndroidManifest.xmlfile - Editor / PC / WebGL / UWP / Console Platforms:
Resources/application_config.txtfile
- iOS / tvOS / visionOS:
- The plugin includes a
link.xmlfile to prevent code from being removed by Unity's code stripping feature. - The
GetChannelName()method caches channel information to avoid repeated reading of configuration files, improving performance.