
All-in-One Solution for Indie Game Development · Empowering Indie Developers' Dreams
📖 Documentation • 🚀 Quick Start • 💬 QQ Group: 467608841
🌐 Language: English | 简体中文 | 繁體中文 | 日本語 | 한국어
This plugin is used to retrieve distribution channel identifiers for multiple platforms in Unity projects (iOS, tvOS, visionOS, Android, Editor, PC, WebGL, UWP, and consoles). It is a submodule of the https://github.com/GameFrameX/GameFrameX project.
Info.plist during iOS builds (if not already set).You can add this plugin to your Unity project in one of the following three ways:
Add via manifest.json:
Add the following to the dependencies node in the manifest.json file in your project's Packages directory:
{
"dependencies": {
"com.gameframex.unity.getchannel": "https://github.com/gameframex/com.gameframex.unity.getchannel.git",
// ... other dependencies
}
}
Via Unity Package Manager using Git URL:
In the Unity Editor, open Window -> Package Manager.
Click the + button in the top-left corner and select Add package from git URL....
Enter the following URL and click Add:
https://github.com/gameframex/com.gameframex.unity.getchannel.git
Download or Clone Repository:
Download or clone this repository into the Packages directory of your Unity project. Unity will automatically recognize and load the plugin.
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:
channel, the script will automatically add an entry with key channel and value default.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.
key you use when calling BlankGetChannel.GetChannelName(string key) matches the key name you set in the corresponding platform's configuration file:
Info.plist file<meta-data> tags in AndroidManifest.xml fileResources/application_config.txt filelink.xml file to prevent code from being removed by Unity's code stripping feature.GetChannelName() method caches channel information to avoid repeated reading of configuration files, improving performance.