Skip to content

Commit 27f0aaa

Browse files
committed
update
1 parent f6d88e3 commit 27f0aaa

Some content is hidden

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

51 files changed

+174
-119
lines changed

Editor/AdsWindowEditor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#if UNITY_EDITOR
22
using UnityEditor;
3-
using VirtueSky.UtilsEditor;
43

54
namespace VirtueSky.Ads
65
{

Editor/AdsWindowEditor.cs.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.

Editor/CreateAsset.cs

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
namespace VirtueSky.Ads
2+
{
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
using UnityEditor;
7+
using UnityEngine;
8+
9+
public static class CreateAsset
10+
{
11+
#if UNITY_EDITOR
12+
public static void CreateScriptableAssets<T>(string path = "")
13+
where T : ScriptableObject
14+
{
15+
var setting = UnityEngine.ScriptableObject.CreateInstance<T>();
16+
UnityEditor.AssetDatabase.CreateAsset(setting, $"{DefaultResourcesPath(path)}/{typeof(T).Name}.asset");
17+
UnityEditor.AssetDatabase.SaveAssets();
18+
UnityEditor.AssetDatabase.Refresh();
19+
20+
Debug.Log(
21+
$"<color=Green>{typeof(T).Name} was created ad {DefaultResourcesPath(path)}/{typeof(T).Name}.asset</color>");
22+
}
23+
24+
public static void CreateScriptableAssets<T>(string path = "", string name = "")
25+
where T : ScriptableObject
26+
{
27+
string newName = name == "" ? typeof(T).Name : name;
28+
var setting = UnityEngine.ScriptableObject.CreateInstance<T>();
29+
UnityEditor.AssetDatabase.CreateAsset(setting, $"{DefaultResourcesPath(path)}/{newName}.asset");
30+
UnityEditor.AssetDatabase.SaveAssets();
31+
UnityEditor.AssetDatabase.Refresh();
32+
33+
Debug.Log(
34+
$"<color=Green>{newName} was created ad {DefaultResourcesPath(path)}/{newName}.asset</color>");
35+
}
36+
37+
public static void CreateScriptableAssetsOnlyName<T>(string path = "") where T : ScriptableObject
38+
{
39+
int assetCounter = 0;
40+
string assetName = $"{typeof(T).Name}";
41+
string assetPath = $"{DefaultResourcesPath(path)}/{assetName}.asset";
42+
43+
while (AssetDatabase.LoadAssetAtPath<T>(assetPath) != null)
44+
{
45+
assetCounter++;
46+
assetPath = $"{DefaultResourcesPath(path)}/{assetName} {assetCounter}.asset";
47+
}
48+
49+
var setting = ScriptableObject.CreateInstance<T>();
50+
51+
UnityEditor.AssetDatabase.CreateAsset(setting, assetPath);
52+
UnityEditor.AssetDatabase.SaveAssets();
53+
UnityEditor.AssetDatabase.Refresh();
54+
55+
Debug.Log(
56+
$"<color=Green>{typeof(T).Name} was created at {assetPath}</color>");
57+
}
58+
59+
60+
public static T CreateAndGetScriptableAsset<T>(string path = "", string assetName = "") where T : ScriptableObject
61+
{
62+
var so = FindAssetAtFolder<T>(new string[] { "Assets" }).FirstOrDefault();
63+
if (so == null)
64+
{
65+
CreateScriptableAssets<T>(path, assetName);
66+
so = FindAssetAtFolder<T>(new string[] { "Assets" }).FirstOrDefault();
67+
}
68+
69+
return so;
70+
}
71+
72+
public static T[] FindAssetAtFolder<T>(string[] paths) where T : Object
73+
{
74+
var list = new List<T>();
75+
var guids = AssetDatabase.FindAssets($"t:{typeof(T).Name}", paths);
76+
foreach (var guid in guids)
77+
{
78+
var asset = AssetDatabase.LoadAssetAtPath<T>(AssetDatabase.GUIDToAssetPath(guid));
79+
if (asset)
80+
{
81+
list.Add(asset);
82+
}
83+
}
84+
85+
return list.ToArray();
86+
}
87+
#endif
88+
89+
90+
public static string DefaultResourcesPath(string path = "")
91+
{
92+
const string defaultResourcePath = "Assets/_Sunflower/Resources";
93+
if (!Directory.Exists(defaultResourcePath + path))
94+
{
95+
Directory.CreateDirectory(defaultResourcePath + path);
96+
}
97+
98+
return defaultResourcePath + path;
99+
}
100+
}
101+
}

Editor/CreateAsset.cs.meta

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

Editor/Virtuesky.Sunflower.Advertising.Editor.asmdef

Lines changed: 0 additions & 19 deletions
This file was deleted.

Runtime/Admob.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.

Runtime/Admob/AdmobClient.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.

Runtime/Admob/AdmobClient/AdmobAdClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
using GoogleMobileAds.Api;
33
#endif
44
using UnityEngine;
5-
using VirtueSky.Attributes;
6-
using VirtueSky.Core;
5+
6+
//using VirtueSky.Attributes;
77

88
namespace VirtueSky.Ads
99
{
1010
public class AdmobAdClient : AdClient
1111
{
12-
[ReadOnly, SerializeField, TextArea] string AppIdTest = "ca-app-pub-3940256099942544~3347511713";
12+
//[ReadOnly, SerializeField, TextArea] string AppIdTest = "ca-app-pub-3940256099942544~3347511713";
1313

1414
public override void Initialize()
1515
{

Runtime/Admob/AdmobClient/AdmobAdClient.cs.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.

Runtime/Admob/AdmodUnitVariable.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.

0 commit comments

Comments
 (0)