Skip to content

Commit

Permalink
[重构]
Browse files Browse the repository at this point in the history
1. 修改宏定义顺序
  • Loading branch information
AlianBlank committed Jul 21, 2023
1 parent 85d9efa commit efd7119
Show file tree
Hide file tree
Showing 23 changed files with 118 additions and 55 deletions.
36 changes: 0 additions & 36 deletions .gitignore

This file was deleted.

File renamed without changes.
7 changes: 7 additions & 0 deletions LICENSE.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions BlankGetChannel.meta → Runtime.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Runtime/BlankGetChannel.Runtime.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "BlankGetChannel.Runtime",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Runtime/BlankGetChannel.Runtime.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 16 additions & 13 deletions BlankGetChannel.cs → Runtime/BlankGetChannel.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#if UNITY_IOS
using System.Runtime.InteropServices;
#endif
using System;
using System.IO;
using LuaInterface;
using UnityEngine;

/// <summary>
/// 获取渠道名称
/// Android:
/// 需要在主启动的Activity 中添加
/// <meta-data android:name="appchannel" android:value="android_cn_yyyl" />
/// <meta-data android:name="channel" android:value="android_cn_taptap" />
///
/// iOS :
/// 需要在Info.plist中添加
Expand All @@ -20,31 +18,36 @@
/// </summary>
public sealed class BlankGetChannel
{

#if UNITY_IOS

[DllImport("__Internal")]
private static extern string getChannelName(string channelKey);

#endif
/// <summary>
/// 获取渠道值
/// </summary>
public static string GetChannelName(string channelKey)
public static string GetChannelName(string channelKey = "channel")
{
string channelName = "unknown";
#if UNITY_STANDALONE || UNITY_EDITOR
string channel = File.ReadAllText(Application.streamingAssetsPath + "/channel.txt");
if (!string.IsNullOrEmpty(channel))
string path = Application.streamingAssetsPath + "/channel.txt";
if (File.Exists(path))
{
channelName = channel;
string channel = File.ReadAllText(Application.streamingAssetsPath + "/channel.txt");
if (!string.IsNullOrEmpty(channel))
{
channelName = channel;
}
}

#elif UNITY_ANDROID
AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.alianhome.getchannel.MainActivity");
channelName = androidJavaClass.CallStatic<string>("GetChannel", channelKey);
using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.alianhome.getchannel.MainActivity"))
{
channelName = androidJavaClass.CallStatic<string>("GetChannel", channelKey);
}
#elif UNITY_IOS
channelName= getChannelName(channelKey);
channelName = getChannelName(channelKey);
#endif
return channelName;
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions Runtime/link.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<linker>
<assembly fullname="BlankGetChannel.Runtime" preserve="all"/>
</linker>
3 changes: 3 additions & 0 deletions Runtime/link.xml.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Sample.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Sample/BlankGetChannel.Sample.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "BlankGetChannel.Sample",
"references": [
"BlankGetChannel.Runtime"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
3 changes: 3 additions & 0 deletions Sample/BlankGetChannel.Sample.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "com.alianblank.blankgetchannel",
"displayName": "Blank Get Channel",
"version": "1.0.0",
"unity": "2017.1",
"description": "获取渠道信息",
"author": {
"name": "alianblank",
"url": "https://github.com/AlianBlank/BlankGetChannel"
},
"samples": [
{
"displayName": "Samples",
"description": "Samples",
"path": "Samples~"
}
],
"repository": {
"type": "git",
"url": "https://github.com/AlianBlank/BlankGetChannel.git"
},
"relatedPackages": {},
"type": "library"
}
7 changes: 7 additions & 0 deletions package.json.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit efd7119

Please sign in to comment.