Skip to content

增加npm run format指令,自动格式化全部文件。 #836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.28.2",
"commands": [
"dotnet-csharpier"
],
"rollForward": false
}
}
}
34 changes: 34 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true

#### Core EditorConfig Options ####

[*]
# Indentation and spacing: https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties
indent_style = space
indent_size = 4
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

# C# files
[*.cs]
# C# formatting options: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

#### .NET Coding Conventions ####

# this. and Me. preferences
dotnet_style_qualification_for_method = true

#### Diagnostic configuration ####

# CA1000: Do not declare static members on generic types
dotnet_diagnostic.CA1000.severity = warning
71 changes: 41 additions & 30 deletions Demo/API_V2/Assets/API/Ad/AdWithAudio/AdWithAudio.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
using UnityEngine;
using WeChatWASM;
using UnityEngine.UI;
using UnityEngine.Networking;
using System;
using System.Collections;
using System.Collections.Generic;

using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Networking;
using UnityEngine.Networking;
using UnityEngine.UI;
using WeChatWASM;

public class AdWithAudio : Details
{

private WXRewardedVideoAd _rewardedVideoAd;
public AudioSource audioSource;
public AudioClip audioClipCDN;

private void Start()
{
StartCoroutine(LoadCDNAudio());


// 创建激励视频广告组件
_rewardedVideoAd = WX.CreateRewardedVideoAd(new WXCreateRewardedVideoAdParam()
_rewardedVideoAd = WX.CreateRewardedVideoAd(
new WXCreateRewardedVideoAdParam()
{
// adUnitId 请填写自己的广告位 ID
adUnitId = "adunit-881d549c5a14a7e3"
}
);

_rewardedVideoAd.OnError(err =>
{
// adUnitId 请填写自己的广告位 ID
adUnitId = "adunit-881d549c5a14a7e3"
});

_rewardedVideoAd.OnError(err => {
Debug.Log(JsonUtility.ToJson(err));
});

GameManager.Instance.detailsController.BindExtraButtonAction(0, PlayCDN);
}

Expand All @@ -49,7 +49,8 @@ IEnumerator LoadCDNAudio()
// 添加 AudioSource 组件
audioSource = newGameObject.AddComponent<AudioSource>();

string uriString = "https://res.wx.qq.com/wechatgame/product/webpack/userupload/20220901/211827/CallMeTeenTop.mp3";
string uriString =
"https://res.wx.qq.com/wechatgame/product/webpack/userupload/20220901/211827/CallMeTeenTop.mp3";
Uri uri = new Uri(uriString);
UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(uri, AudioType.MPEG);
yield return request.SendWebRequest();
Expand Down Expand Up @@ -78,25 +79,35 @@ public void PlayCDN()
// 展示广告
private void ShowAd()
{
_rewardedVideoAd.Show(res => {
Debug.Log("Show success");
Debug.Log(JsonUtility.ToJson(res));
}, err => {
Debug.Log(JsonUtility.ToJson(err));
_rewardedVideoAd.Load(res => {
Debug.Log("load success");
_rewardedVideoAd.Show();
}, err => {
Debug.Log("load fail");
_rewardedVideoAd.Show(
res =>
{
Debug.Log("Show success");
Debug.Log(JsonUtility.ToJson(res));
},
err =>
{
Debug.Log(JsonUtility.ToJson(err));
});
});
_rewardedVideoAd.Load(
res =>
{
Debug.Log("load success");
_rewardedVideoAd.Show();
},
err =>
{
Debug.Log("load fail");
Debug.Log(JsonUtility.ToJson(err));
}
);
}
);
}


public void Destroy()
{
if (audioSource != null) {
if (audioSource != null)
{
audioSource.clip = null;
audioSource = null;
}
Expand Down
78 changes: 39 additions & 39 deletions Demo/API_V2/Assets/API/Ad/BannerAd/BannerAd.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using UnityEngine;
using UnityEngine;
using WeChatWASM;

public class BannerAd : Details
{
private WXBannerAd _bannerAd;

private bool _isShow = false;

private void Start()
{
// 绑定按钮事件
Expand All @@ -21,33 +21,42 @@ protected override void TestAPI(string[] args)
// adUnitId 请填写自己的广告位 ID
// 创建预设的 Banner 广告
_bannerAd = WX.CreateFixedBottomMiddleBannerAd("adunit-xxxxxxxxxxxxxxxx", 30, 200);

_bannerAd.OnLoad((res) =>
{
WX.ShowModal(new ShowModalOption()

_bannerAd.OnLoad(
(res) =>
{
content = "BannerAd OnLoad Result:" + JsonUtility.ToJson(res)
});
});
_bannerAd.OnError((res) =>
{
WX.ShowModal(new ShowModalOption()
WX.ShowModal(
new ShowModalOption()
{
content = "BannerAd OnLoad Result:" + JsonUtility.ToJson(res)
}
);
}
);
_bannerAd.OnError(
(res) =>
{
content = "BannerAd onError Result:" + JsonUtility.ToJson(res)
});
});
_bannerAd.OnResize((res) =>
{
WX.ShowModal(new ShowModalOption()
WX.ShowModal(
new ShowModalOption()
{
content = "BannerAd onError Result:" + JsonUtility.ToJson(res)
}
);
}
);
_bannerAd.OnResize(
(res) =>
{
content = "BannerAd onResize Result:" + JsonUtility.ToJson(res)
});
});

WX.ShowToast(new ShowToastOption()
{
title = "已创建广告"
});
WX.ShowModal(
new ShowModalOption()
{
content = "BannerAd onResize Result:" + JsonUtility.ToJson(res)
}
);
}
);

WX.ShowToast(new ShowToastOption() { title = "已创建广告" });
}

// 切换广告显示状态
Expand All @@ -57,30 +66,21 @@ private void SwitchAdState()
{
// 隐藏广告
_bannerAd.Hide();
WX.ShowToast(new ShowToastOption()
{
title = "已隐藏广告"
});
WX.ShowToast(new ShowToastOption() { title = "已隐藏广告" });
}
else
{
// 展示广告
_bannerAd.Show();
WX.ShowToast(new ShowToastOption()
{
title = "已展示广告"
});
WX.ShowToast(new ShowToastOption() { title = "已展示广告" });
}
}

// 销毁广告
private void DestroyAd()
{
_bannerAd.Destroy();
WX.ShowToast(new ShowToastOption()
{
title = "已销毁广告"
});
WX.ShowToast(new ShowToastOption() { title = "已销毁广告" });
}

private void OnDestroy()
Expand Down
Loading
Loading