Browse Source

- Prototype ver.1.5

dll_rework Prototype_1.5
Seraph 4 years ago
parent
commit
de6dec1721
  1. 3
      .gitignore
  2. 8
      Assets/Builds.meta
  3. 7
      Assets/Builds/Core_1.3.unitypackage.meta
  4. 7
      Assets/Builds/Core_1.4.unitypackage.meta
  5. 0
      Assets/Core/Ads/RewardedButton.cs
  6. 0
      Assets/Core/Ads/RewardedButton.cs.meta
  7. 178
      Assets/Core/Tools/Editor/UnusedAssetsMarker.cs
  8. 11
      Assets/Core/Tools/Editor/UnusedAssetsMarker.cs.meta
  9. 2
      Assets/Core/Window/Editor/CoreSettingsWindow.cs
  10. BIN
      Builds/Core_1.3.unitypackage
  11. BIN
      Builds/Core_1.4.unitypackage
  12. BIN
      Builds/Core_1.5.unitypackage

3
.gitignore

@ -5,8 +5,6 @@
/[Ll]ibrary/ /[Ll]ibrary/
/[Tt]emp/ /[Tt]emp/
/[Oo]bj/ /[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/ /[Ll]ogs/
/[Uu]ser[Ss]ettings/ /[Uu]ser[Ss]ettings/
@ -57,7 +55,6 @@ sysinfo.txt
# Builds # Builds
*.apk *.apk
*.unitypackage
# Crashlytics generated file # Crashlytics generated file
crashlytics-build.properties crashlytics-build.properties

8
Assets/Builds.meta

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 344d15cb1e8bb3d4f938bacdd1ca85b9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

7
Assets/Builds/Core_1.3.unitypackage.meta

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 146af9f28785df94e96dd4051f3c1f0e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

7
Assets/Builds/Core_1.4.unitypackage.meta

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 63abef4a9c33fec46880ba4a9d4a2499
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

0
Assets/CoreCustumization/Scripts/RewardedButton.cs → Assets/Core/Ads/RewardedButton.cs

0
Assets/CoreCustumization/Scripts/RewardedButton.cs.meta → Assets/Core/Ads/RewardedButton.cs.meta

178
Assets/Core/Tools/Editor/UnusedAssetsMarker.cs

@ -0,0 +1,178 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
[InitializeOnLoad]
public static class UnusedAssetsMarker
{
private struct FolderInfo
{
public int usedCount;
public int unusedCount;
}
private static List<string> _usedAssets = new List<string>();
private static List<string> _allAssets = new List<string>();
private static Dictionary<string, FolderInfo> _foldersInfo = new Dictionary<string, FolderInfo>();
private static Dictionary<string, bool> _assetsInfo = new Dictionary<string, bool>();
static UnusedAssetsMarker()
{
ResearchDependecies();
EditorApplication.projectWindowItemOnGUI += DrawAssetDetails;
}
[MenuItem("Core/Research unused assets", false, 0)]
private static void ResearchDependecies()
{
_usedAssets = new List<string>();
_allAssets = AssetDatabase.GetAllAssetPaths().ToList();
_foldersInfo = new Dictionary<string, FolderInfo>();
for (int i = 0; i < EditorBuildSettings.scenes.Length; i++)
{
string scenePath = EditorBuildSettings.scenes[i].path;
string[] dependencies = AssetDatabase.GetDependencies(scenePath);
_usedAssets.AddRange(dependencies);
}
Object[] resources = Resources.LoadAll("");
for (int i = 0; i < resources.Length; i++)
{
_usedAssets.AddRange(AssetDatabase.GetDependencies(AssetDatabase.GetAssetPath(resources[i])));
}
}
private static void DrawAssetDetails(string guid, Rect rect)
{
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
if (Application.isPlaying || Event.current.type != EventType.Repaint || IsInvalidFile(assetPath) || assetPath == "Assets")
{
GUI.backgroundColor = Color.white;
return;
}
if (AssetDatabase.IsValidFolder(assetPath))
{
if (IsMainListAsset(rect))
{
int usedCount = 0;
int unusedCount = 0;
if (_foldersInfo.ContainsKey(assetPath))
{
usedCount = _foldersInfo[assetPath].usedCount;
unusedCount = _foldersInfo[assetPath].unusedCount;
}
else
{
string[] assetsInFolder = _allAssets.Where(path => path.Contains(assetPath) && !AssetDatabase.IsValidFolder(path)).ToArray();
for (int i = 0; i < assetsInFolder.Length; i++)
{
if (IsAssetsUsed(assetsInFolder[i]) || IsInvalidFile(assetsInFolder[i]))
usedCount++;
else
unusedCount++;
}
_foldersInfo.Add(assetPath, new FolderInfo { usedCount = usedCount, unusedCount = unusedCount });
}
GUIStyle style = new GUIStyle(EditorStyles.label);
style.alignment = TextAnchor.MiddleRight;
Rect newRect = rect;
newRect.x += rect.width - 305;
newRect.width = 200;
GUI.Label(newRect, $"Used assets count: {usedCount}");
newRect = rect;
newRect.x += rect.width - 155;
newRect.width = 200;
GUI.Label(newRect, $"Unused assets count: {unusedCount}");
}
GUI.backgroundColor = Color.white;
return;
}
if (AssetDatabase.LoadAssetAtPath<Object>(assetPath) != null) {
bool isUsed = false;
if (_assetsInfo.ContainsKey(assetPath))
isUsed = _assetsInfo[assetPath];
else
{
isUsed = IsAssetsUsed(assetPath);
_assetsInfo.Add(assetPath, isUsed);
}
if (isUsed)
{
GUI.backgroundColor = Color.white;
return;
}
if (IsMainListAsset(rect))
{
Rect newRect = rect;
newRect.x += rect.width - 55;
newRect.width = 100;
GUIStyle style = new GUIStyle(EditorStyles.label);
style.alignment = TextAnchor.MiddleRight;
GUI.Label(newRect, "Unused");
}
if (isUsed)
GUI.color = Color.clear;
else
GUI.color = Color.red;
GUI.Box(rect, "");
GUI.color = Color.white;
}
}
private static bool IsMainListAsset(Rect rect)
{
if (rect.height > 20)
return false;
if (rect.x > 16)
return false;
return true;
}
private static bool IsInvalidFile(string path)
{
return
Path.GetExtension(path) == ".cs" ||
Path.GetExtension(path) == ".dll" ||
Path.GetExtension(path) == ".unity" ||
Regex.IsMatch(path, "[\\/\\\\]Editor[\\/\\\\]") == true ||
Regex.IsMatch(path, "[\\/\\\\]Resources[\\/\\\\]") == true ||
Regex.IsMatch(path, "[\\/\\\\]Plugins[\\/\\\\]") == true;
}
private static bool IsAssetsUsed(string path)
{
return _usedAssets.Contains(path);
}
}

11
Assets/Core/Tools/Editor/UnusedAssetsMarker.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 58c6268c557aa8c4fa61e6db42d2af44
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

2
Assets/Core/Window/Editor/CoreSettingsWindow.cs

@ -24,7 +24,7 @@ namespace Core.Settings
private bool m_IsInCompilation = false; private bool m_IsInCompilation = false;
[MenuItem("Window/Core Settings", false, -1000)] [MenuItem("Core/Settings", false, 1000)]
public static void Init() public static void Init()
{ {
window = EditorWindow.GetWindow<CoreSettingsWindow>("Core Settings", typeof(SceneView)); window = EditorWindow.GetWindow<CoreSettingsWindow>("Core Settings", typeof(SceneView));

BIN
Builds/Core_1.3.unitypackage

Binary file not shown.

BIN
Builds/Core_1.4.unitypackage

Binary file not shown.

BIN
Builds/Core_1.5.unitypackage

Binary file not shown.
Loading…
Cancel
Save