Skip to content

Commit b5751d0

Browse files
committed
[modify] build error android il2cpp
1 parent 5bd444f commit b5751d0

File tree

9 files changed

+218
-210
lines changed

9 files changed

+218
-210
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Assets/AssetStoreTools*
88
# Visual Studio cache directory
99
.vs/
1010

11+
# Rider cache directory
12+
.idea/
13+
Assets/Plugins/Editor.meta
14+
Assets/Plugins/Editor/JetBrains/*
15+
Assets/Plugins/Editor/JetBrains.meta
16+
1117
# Autogenerated VS/MD/Consulo solution and project files
1218
ExportedObj/
1319
.consulo/

Assets/Editor/ExportPackage.cs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
using UnityEngine;
2-
using UnityEditor;
3-
using System.IO;
4-
5-
public class ExportPackage
6-
{
1+
using UnityEngine;
2+
using UnityEditor;
3+
using System.IO;
4+
5+
public class ExportPackage
6+
{
77
private readonly static string[] Paths = {
88
"Assets/Plugins/MemoryInfoPlugin",
9-
};
10-
11-
private const string ReadMe = "README.md";
12-
private const string License = "LICENSE";
13-
14-
[MenuItem("Assets/Export MemoryInfoPlugin")]
15-
private static void Export()
16-
{
17-
string readmePath = Path.Combine(Application.dataPath, "Plugins/MemoryInfoPlugin", ReadMe);
18-
string licensePath = Path.Combine(Application.dataPath, "Plugins/MemoryInfoPlugin", License);
19-
File.Copy(Path.Combine(Application.dataPath, "..", ReadMe), readmePath);
20-
File.Copy(Path.Combine(Application.dataPath, "..", License), licensePath);
21-
AssetDatabase.Refresh();
22-
23-
AssetDatabase.ExportPackage(Paths, "MemoryInfoPlugin-for-Unity.unitypackage", ExportPackageOptions.Recurse);
24-
Debug.Log("Export complete!");
25-
26-
File.Delete(readmePath);
27-
File.Delete(licensePath);
28-
File.Delete(readmePath + ".meta");
29-
File.Delete(licensePath + ".meta");
30-
AssetDatabase.Refresh();
31-
}
32-
}
9+
};
10+
11+
private const string ReadMe = "README.md";
12+
private const string License = "LICENSE";
13+
14+
[MenuItem("Assets/Export MemoryInfoPlugin")]
15+
private static void Export()
16+
{
17+
string readmePath = Path.Combine(Application.dataPath, "Plugins/MemoryInfoPlugin", ReadMe);
18+
string licensePath = Path.Combine(Application.dataPath, "Plugins/MemoryInfoPlugin", License);
19+
File.Copy(Path.Combine(Application.dataPath, "..", ReadMe), readmePath);
20+
File.Copy(Path.Combine(Application.dataPath, "..", License), licensePath);
21+
AssetDatabase.Refresh();
22+
23+
AssetDatabase.ExportPackage(Paths, "MemoryInfoPlugin-for-Unity.unitypackage", ExportPackageOptions.Recurse);
24+
Debug.Log("Export complete!");
25+
26+
File.Delete(readmePath);
27+
File.Delete(licensePath);
28+
File.Delete(readmePath + ".meta");
29+
File.Delete(licensePath + ".meta");
30+
AssetDatabase.Refresh();
31+
}
32+
}
Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
using System;
2-
using System.Collections;
3-
using UnityEngine;
4-
using UnityEngine.UI;
5-
6-
namespace MemoryInfo.Example
1+
using System.Collections;
2+
using UnityEngine;
3+
using UnityEngine.UI;
4+
5+
namespace MemoryInfo.Example
76
{
87
public sealed class Example : MonoBehaviour
9-
{
10-
[SerializeField] private Text _text = null;
8+
{
9+
[SerializeField] private Text _text = null;
1110

1211
private IEnumerator Start()
1312
{
14-
var plugin = new MemoryInfoPlugin();
15-
16-
while(true)
17-
{
18-
var info = plugin.GetMemoryInfo();
19-
_text.text = string.Format("{0}/{1} KB ({2}%)", info.UsedSize, info.TotalSize, (int)(100f * info.UsedSize / info.TotalSize));
20-
yield return new WaitForSeconds(1.0f);
13+
var plugin = new MemoryInfoPlugin();
14+
15+
while(true)
16+
{
17+
var info = plugin.GetMemoryInfo();
18+
_text.text = string.Format("{0}/{1} KB ({2}%)", info.UsedSize, info.TotalSize, (int)(100f * info.UsedSize / info.TotalSize));
19+
yield return new WaitForSeconds(1.0f);
2120
}
2221
}
23-
}
24-
}
22+
}
23+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
2-
3-
namespace MemoryInfo.Internal
1+
using System;
2+
3+
namespace MemoryInfo.Internal
44
{
5-
public interface IPlatform : IDisposable
6-
{
7-
MemoryInfo GetMemoryInfo();
8-
}
9-
}
5+
public interface IPlatform : IDisposable
6+
{
7+
MemoryInfo GetMemoryInfo();
8+
}
9+
}
Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,60 @@
1-
#if UNITY_ANDROID
2-
using System;
3-
using UnityEngine;
4-
5-
namespace MemoryInfo.Internal
1+
#if UNITY_ANDROID
2+
using System;
3+
using UnityEngine;
4+
5+
namespace MemoryInfo.Internal
66
{
77
public sealed class MemoryInfoForAndroid : IPlatform
8-
{
9-
private readonly AndroidJavaObject _activityManager;
10-
11-
private readonly AndroidJavaObject _memoryInfo;
12-
13-
private readonly AndroidJavaObject [] _memoryInfos;
14-
15-
public MemoryInfoForAndroid()
16-
{
17-
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
18-
using (AndroidJavaClass contextClass = new AndroidJavaClass("android.content.Context"))
19-
using (AndroidJavaClass processClass = new AndroidJavaClass("android.os.Process"))
20-
using (AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
21-
using (AndroidJavaObject context = activity.Call<AndroidJavaObject>("getApplicationContext"))
22-
{
23-
_activityManager = context.Call<AndroidJavaObject>("getSystemService", contextClass.GetStatic<string>("ACTIVITY_SERVICE"));
8+
{
9+
private readonly AndroidJavaObject _activityManager;
10+
11+
private readonly AndroidJavaObject _memoryInfo;
12+
13+
private readonly AndroidJavaObject [] _memoryInfos;
14+
15+
public MemoryInfoForAndroid()
16+
{
17+
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
18+
using (AndroidJavaClass contextClass = new AndroidJavaClass("android.content.Context"))
19+
using (AndroidJavaClass processClass = new AndroidJavaClass("android.os.Process"))
20+
using (AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
21+
using (AndroidJavaObject context = activity.Call<AndroidJavaObject>("getApplicationContext"))
22+
{
23+
_activityManager = context.Call<AndroidJavaObject>("getSystemService", contextClass.GetStatic<string>("ACTIVITY_SERVICE"));
2424
_memoryInfo = new AndroidJavaObject("android.app.ActivityManager$MemoryInfo");
25-
int[] pids = { processClass.CallStatic<int>("myPid") };
25+
int[] pids = { processClass.CallStatic<int>("myPid") };
2626
_memoryInfos = _activityManager.Call<AndroidJavaObject[]>("getProcessMemoryInfo", pids);
27-
}
28-
}
29-
30-
~MemoryInfoForAndroid()
31-
{
32-
Dispose();
33-
}
34-
35-
public void Dispose()
36-
{
37-
foreach (var memoryInfo in _memoryInfos)
38-
memoryInfo.Dispose();
39-
_memoryInfo.Dispose();
40-
_activityManager.Dispose();
41-
}
42-
43-
MemoryInfo IPlatform.GetMemoryInfo()
44-
{
45-
_activityManager.Call("getMemoryInfo", _memoryInfo);
46-
47-
int usedSize = 0;
48-
foreach (var memoryInfo in _memoryInfos)
49-
{
50-
usedSize += memoryInfo.Call<int>("getTotalPss");
51-
}
52-
27+
}
28+
}
29+
30+
~MemoryInfoForAndroid()
31+
{
32+
Dispose();
33+
}
34+
35+
public void Dispose()
36+
{
37+
foreach (var memoryInfo in _memoryInfos)
38+
memoryInfo.Dispose();
39+
_memoryInfo.Dispose();
40+
_activityManager.Dispose();
41+
}
42+
43+
MemoryInfo IPlatform.GetMemoryInfo()
44+
{
45+
_activityManager.Call("getMemoryInfo", _memoryInfo);
46+
47+
int usedSize = 0;
48+
foreach (var memoryInfo in _memoryInfos)
49+
{
50+
usedSize += memoryInfo.Call<int>("getTotalPss");
51+
}
52+
5353
return new MemoryInfo() {
54-
TotalSize = (int)(_memoryInfo.Get<long>("threshold") / 1024),
54+
TotalSize = (int)(_memoryInfo.Get<long>("threshold") / 1024),
5555
UsedSize = usedSize,
56-
};
56+
};
5757
}
58-
}
58+
}
5959
}
60-
#endif
60+
#endif
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
#if UNITY_EDITOR
2-
using System;
3-
using UnityEngine.Profiling;
4-
5-
namespace MemoryInfo.Internal
1+
#if UNITY_EDITOR
2+
using System;
3+
using UnityEngine.Profiling;
4+
5+
namespace MemoryInfo.Internal
66
{
77
public sealed class MemoryInfoForEditor : IPlatform
8-
{
9-
void IDisposable.Dispose()
10-
{
11-
12-
}
13-
14-
MemoryInfo IPlatform.GetMemoryInfo()
15-
{
8+
{
9+
void IDisposable.Dispose()
10+
{
11+
12+
}
13+
14+
MemoryInfo IPlatform.GetMemoryInfo()
15+
{
1616
return new MemoryInfo() {
17-
TotalSize = (int)(Profiler.GetTotalReservedMemoryLong() / 1024),
17+
TotalSize = (int)(Profiler.GetTotalReservedMemoryLong() / 1024),
1818
UsedSize = (int)(Profiler.GetTotalAllocatedMemoryLong() / 1024),
19-
};
19+
};
2020
}
21-
}
21+
}
2222
}
23-
#endif
23+
#endif
Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1-
using System;
2-
using System.Runtime.InteropServices;
3-
4-
namespace MemoryInfo.Internal
1+
#if UNITY_IOS
2+
using System;
3+
using System.Runtime.InteropServices;
4+
5+
namespace MemoryInfo.Internal
56
{
67
public sealed class MemoryInfoForIOS : IPlatform
7-
{
8-
[DllImport("__Internal")]
9-
private static extern uint _GetUsedMemorySize();
10-
11-
[DllImport("__Internal")]
12-
private static extern uint _GetFreeMemorySize();
13-
14-
[DllImport("__Internal")]
15-
private static extern uint _GetTotalMemorySize();
8+
{
9+
[DllImport("__Internal")]
10+
private static extern uint _GetUsedMemorySize();
11+
12+
[DllImport("__Internal")]
13+
private static extern uint _GetFreeMemorySize();
14+
15+
[DllImport("__Internal")]
16+
private static extern uint _GetTotalMemorySize();
17+
18+
void IDisposable.Dispose()
19+
{
20+
21+
}
1622

17-
void IDisposable.Dispose()
18-
{
19-
20-
}
21-
22-
MemoryInfo IPlatform.GetMemoryInfo()
23-
{;
24-
return new MemoryInfo() {
25-
UsedSize = (int)(_GetUsedMemorySize() / 1024),
26-
TotalSize = (int)(_GetTotalMemorySize() / 1024),
27-
};
23+
MemoryInfo IPlatform.GetMemoryInfo()
24+
{;
25+
return new MemoryInfo() {
26+
UsedSize = (int)(_GetUsedMemorySize() / 1024),
27+
TotalSize = (int)(_GetTotalMemorySize() / 1024),
28+
};
2829
}
29-
}
30-
}
30+
}
31+
}
32+
#endif

0 commit comments

Comments
 (0)