Skip to content

Commit 7bb23c3

Browse files
committed
添加demo
1 parent d6efbfe commit 7bb23c3

File tree

227 files changed

+9858
-592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

227 files changed

+9858
-592
lines changed

Demo/API_V2/Assets/API/APISO.asset

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ MonoBehaviour:
1717
- {fileID: 11400000, guid: 82450cc74b3b4439da53b9f0f2298454, type: 2}
1818
- {fileID: 11400000, guid: b34629c67a7664a428561dd0b3621995, type: 2}
1919
- {fileID: 11400000, guid: 9977a581037b84833a32b508e00eb1a2, type: 2}
20-
- {fileID: 11400000, guid: 6f6fdc677ed96437eb1fa0e7e272b6d8, type: 2}
2120
- {fileID: 11400000, guid: 56f316e0e10ba419bbf19bd7a68bfc4c, type: 2}
2221
- {fileID: 11400000, guid: 6f0972f5fdc56c543b23c9873d760bf5, type: 2}
2322
- {fileID: 11400000, guid: a461b8cd70d9e4e23ad1cc953bec31e9, type: 2}
2423
- {fileID: 11400000, guid: 7ef06699cee7846b7823e4cc421418eb, type: 2}
2524
- {fileID: 11400000, guid: 55de20d536f8c4689bbd80553d87fe46, type: 2}
2625
- {fileID: 11400000, guid: f2c56d751bb7c4c398db7c1db352517d, type: 2}
26+
- {fileID: 11400000, guid: b4a6196f623dd4435a4f3bd70af92d06, type: 2}
27+
- {fileID: 11400000, guid: 6f6fdc677ed96437eb1fa0e7e272b6d8, type: 2}
2728
- {fileID: 11400000, guid: 8c2a99491f3c0446097220cd580dfe38, type: 2}
2829
- {fileID: 11400000, guid: 59792dcce94fc48f6ab5654a02c78c6d, type: 2}
2930
- {fileID: 11400000, guid: b363337bfb49b490e81fbfac3612f793, type: 2}

Demo/API_V2/Assets/API/Ad/AdSO.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ MonoBehaviour:
1515
categoryName: "\u5E7F\u544A"
1616
categorySprite: {fileID: 21300000, guid: 9865c656be3004b6f8d509f0134ccdda, type: 3}
1717
entryList:
18+
- {fileID: 11400000, guid: 3ddfb0b7c42b34030a50164dbdb42595, type: 2}
1819
- {fileID: 11400000, guid: 46bca0e1609784a2f876ea58df90e8b8, type: 2}
1920
- {fileID: 11400000, guid: ab9ad3727f48045839570ecbda60c455, type: 2}
2021
- {fileID: 11400000, guid: 11f09745641b4493b99b3ee8bd3e5334, type: 2}

Demo/API_V2/Assets/API/Download.meta renamed to Demo/API_V2/Assets/API/Ad/AdWithAudio.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
using UnityEngine;
2+
using WeChatWASM;
3+
using UnityEngine.UI;
4+
using UnityEngine.Networking;
5+
using System;
6+
using System.Collections;
7+
using System.Collections.Generic;
8+
9+
using UnityEngine.Audio;
10+
using UnityEngine.Networking;
11+
12+
public class AdWithAudio : Details
13+
{
14+
15+
private WXRewardedVideoAd _rewardedVideoAd;
16+
public AudioSource audioSource;
17+
public AudioClip audioClipCDN;
18+
19+
private void Start()
20+
{
21+
StartCoroutine(LoadCDNAudio());
22+
23+
24+
// 创建激励视频广告组件
25+
_rewardedVideoAd = WX.CreateRewardedVideoAd(new WXCreateRewardedVideoAdParam()
26+
{
27+
// adUnitId 请填写自己的广告位 ID
28+
adUnitId = "adunit-881d549c5a14a7e3"
29+
});
30+
31+
_rewardedVideoAd.OnError(err => {
32+
Debug.Log(JsonUtility.ToJson(err));
33+
});
34+
35+
GameManager.Instance.detailsController.BindExtraButtonAction(0, PlayCDN);
36+
}
37+
38+
// 创建激励视频广告组件并挂载事件、预加载广告
39+
protected override void TestAPI(string[] args)
40+
{
41+
ShowAd();
42+
}
43+
44+
IEnumerator LoadCDNAudio()
45+
{
46+
// 创建一个新的游戏对象
47+
GameObject newGameObject = new GameObject("New GameObject");
48+
49+
// 添加 AudioSource 组件
50+
audioSource = newGameObject.AddComponent<AudioSource>();
51+
52+
string uriString = "https://res.wx.qq.com/wechatgame/product/webpack/userupload/20220901/211827/CallMeTeenTop.mp3";
53+
Uri uri = new Uri(uriString);
54+
UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(uri, AudioType.MPEG);
55+
yield return request.SendWebRequest();
56+
if (request.result == UnityWebRequest.Result.Success)
57+
{
58+
audioClipCDN = DownloadHandlerAudioClip.GetContent(request);
59+
// yield return new WaitUntil(() => audioClipCDN.loadState == AudioDataLoadState.Loaded);
60+
// Debug.Log("audioClipCDN loaded, clip length: " + audioClipCDN.length);
61+
}
62+
else
63+
{
64+
Debug.Log("request error: " + request.error);
65+
}
66+
}
67+
68+
public void PlayCDN()
69+
{
70+
if (audioClipCDN != null)
71+
{
72+
audioSource.clip = audioClipCDN;
73+
audioSource.loop = true;
74+
audioSource.Play();
75+
}
76+
}
77+
78+
// 展示广告
79+
private void ShowAd()
80+
{
81+
_rewardedVideoAd.Show(res => {
82+
Debug.Log("Show success");
83+
Debug.Log(JsonUtility.ToJson(res));
84+
}, err => {
85+
Debug.Log(JsonUtility.ToJson(err));
86+
_rewardedVideoAd.Load(res => {
87+
Debug.Log("load success");
88+
_rewardedVideoAd.Show();
89+
}, err => {
90+
Debug.Log("load fail");
91+
Debug.Log(JsonUtility.ToJson(err));
92+
});
93+
});
94+
}
95+
96+
97+
public void Destroy()
98+
{
99+
if (audioSource != null) {
100+
audioSource.clip = null;
101+
audioSource = null;
102+
}
103+
}
104+
}

Demo/API_V2/Assets/API/Ad/AdWithAudio/AdWithAudio.cs.meta

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: fb48e4613a53bb941a20036d7c08fefb, type: 3}
13+
m_Name: AdWithAudioSO
14+
m_EditorClassIdentifier:
15+
entryScriptTypeName: AdWithAudio
16+
entryName: "\u5E7F\u544A\u548C\u97F3\u4E50"
17+
entryAPI:
18+
entryDescription:
19+
optionList: []
20+
initialButtonText: "\u5C55\u793A\u5E7F\u544A"
21+
extraButtonList:
22+
- buttonText: "\u64AD\u653E\u97F3\u4E50"
23+
initialResultList: []

Demo/API_V2/Assets/API/Ad/AdWithAudio/AdWithAudioSO.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!1 &4959676054870837107
4+
GameObject:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
serializedVersion: 6
10+
m_Component:
11+
- component: {fileID: 4959676054870837109}
12+
- component: {fileID: 4959676054870837108}
13+
m_Layer: 0
14+
m_Name: Audio Source
15+
m_TagString: Untagged
16+
m_Icon: {fileID: 0}
17+
m_NavMeshLayer: 0
18+
m_StaticEditorFlags: 0
19+
m_IsActive: 1
20+
--- !u!4 &4959676054870837109
21+
Transform:
22+
m_ObjectHideFlags: 0
23+
m_CorrespondingSourceObject: {fileID: 0}
24+
m_PrefabInstance: {fileID: 0}
25+
m_PrefabAsset: {fileID: 0}
26+
m_GameObject: {fileID: 4959676054870837107}
27+
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
28+
m_LocalPosition: {x: -163.43658, y: 990.03503, z: -14.330248}
29+
m_LocalScale: {x: 1, y: 1, z: 1}
30+
m_ConstrainProportionsScale: 0
31+
m_Children: []
32+
m_Father: {fileID: 0}
33+
m_RootOrder: 0
34+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35+
--- !u!82 &4959676054870837108
36+
AudioSource:
37+
m_ObjectHideFlags: 0
38+
m_CorrespondingSourceObject: {fileID: 0}
39+
m_PrefabInstance: {fileID: 0}
40+
m_PrefabAsset: {fileID: 0}
41+
m_GameObject: {fileID: 4959676054870837107}
42+
m_Enabled: 1
43+
serializedVersion: 4
44+
OutputAudioMixerGroup: {fileID: 0}
45+
m_audioClip: {fileID: 0}
46+
m_PlayOnAwake: 1
47+
m_Volume: 1
48+
m_Pitch: 1
49+
Loop: 0
50+
Mute: 0
51+
Spatialize: 0
52+
SpatializePostEffects: 0
53+
Priority: 128
54+
DopplerLevel: 1
55+
MinDistance: 1
56+
MaxDistance: 500
57+
Pan2D: 0
58+
rolloffMode: 0
59+
BypassEffects: 0
60+
BypassListenerEffects: 0
61+
BypassReverbZones: 0
62+
rolloffCustomCurve:
63+
serializedVersion: 2
64+
m_Curve:
65+
- serializedVersion: 3
66+
time: 0
67+
value: 1
68+
inSlope: 0
69+
outSlope: 0
70+
tangentMode: 0
71+
weightedMode: 0
72+
inWeight: 0.33333334
73+
outWeight: 0.33333334
74+
- serializedVersion: 3
75+
time: 1
76+
value: 0
77+
inSlope: 0
78+
outSlope: 0
79+
tangentMode: 0
80+
weightedMode: 0
81+
inWeight: 0.33333334
82+
outWeight: 0.33333334
83+
m_PreInfinity: 2
84+
m_PostInfinity: 2
85+
m_RotationOrder: 4
86+
panLevelCustomCurve:
87+
serializedVersion: 2
88+
m_Curve:
89+
- serializedVersion: 3
90+
time: 0
91+
value: 0
92+
inSlope: 0
93+
outSlope: 0
94+
tangentMode: 0
95+
weightedMode: 0
96+
inWeight: 0.33333334
97+
outWeight: 0.33333334
98+
m_PreInfinity: 2
99+
m_PostInfinity: 2
100+
m_RotationOrder: 4
101+
spreadCustomCurve:
102+
serializedVersion: 2
103+
m_Curve:
104+
- serializedVersion: 3
105+
time: 0
106+
value: 0
107+
inSlope: 0
108+
outSlope: 0
109+
tangentMode: 0
110+
weightedMode: 0
111+
inWeight: 0.33333334
112+
outWeight: 0.33333334
113+
m_PreInfinity: 2
114+
m_PostInfinity: 2
115+
m_RotationOrder: 4
116+
reverbZoneMixCustomCurve:
117+
serializedVersion: 2
118+
m_Curve:
119+
- serializedVersion: 3
120+
time: 0
121+
value: 1
122+
inSlope: 0
123+
outSlope: 0
124+
tangentMode: 0
125+
weightedMode: 0
126+
inWeight: 0.33333334
127+
outWeight: 0.33333334
128+
m_PreInfinity: 2
129+
m_PostInfinity: 2
130+
m_RotationOrder: 4

Demo/API_V2/Assets/API/Ad/AdWithAudio/Audio Source.prefab.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Demo/API_V2/Assets/API/Chat/ChatManager/ChatManager.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
public class ChatManager : Details
66
{
7-
// private static WXChat WxChat = null;
7+
private static WXChat WxChat = null;
88

99
private void Start()
1010
{
1111
CreateChat();
12-
SetTabs();
1312

1413
// 绑定额外的按钮操作
1514
GameManager.Instance.detailsController.BindExtraButtonAction(0, Hide);
@@ -31,9 +30,8 @@ private void CreateChat()
3130
Debug.Log("已创建");
3231
return;
3332
}
34-
33+
3534
WxChat = WX.CreateMiniGameChat();
36-
Debug.Log("WxChat : " + WxChat);
3735

3836
if (WxChat == null)
3937
{
@@ -45,6 +43,7 @@ private void CreateChat()
4543
WxChat.On("ready", (res) =>
4644
{
4745
Debug.Log("wxChat ready");
46+
SetTabs();
4847
});
4948

5049
WxChat.On("show", (res) =>
@@ -125,7 +124,7 @@ public void Close()
125124
}
126125
}
127126

128-
private void OnDestroy()
127+
public void Destroy()
129128
{
130129
Hide();
131130
}

0 commit comments

Comments
 (0)