Skip to content

Commit

Permalink
SKCell v0.13.2 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyrim07 committed Oct 11, 2023
1 parent 0fcf9b9 commit 1a1b004
Show file tree
Hide file tree
Showing 27 changed files with 768 additions and 125 deletions.
15 changes: 15 additions & 0 deletions Assets/SKCell/Common/ActiveOnAwake.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class ActiveOnAwake : MonoBehaviour
{
public GameObject target;
public bool active = false;
private void Awake()
{
target.SetActive(active);
}

}
11 changes: 11 additions & 0 deletions Assets/SKCell/Common/ActiveOnAwake.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Assets/SKCell/Common/SKReferenceHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ namespace SKCell {
[AddComponentMenu("SKCell/SKReferenceHolder")]
public class SKReferenceHolder : MonoBehaviour
{
[Header("Basic")]
[SKFolder("Basic")]
public int intValue;
public float floatValue;
public bool boolValue;
public string stringValue;
public char charValue;

[Header("Unity Basic")]
[SKFolder("Unity Basic")]
public GameObject gameObjectValue;
public Transform transformValue;
public ParticleSystem particleSystemValue;


[Header("Unity UI")]
[SKFolder("Unity UI")]
public Text textValue;
public Image imageValue;
public Canvas canvasValue;
public CanvasGroup canvasGroupValue;
public ScrollRect scrollRectValue;
public Scrollbar scrollBarValue;

[Header("SKCell")]
[SKFolder("SKCell")]
public SKText skTextValue;
public SKImage skImageValue;
public SKSlider skSliderValue;
Expand All @@ -38,7 +38,7 @@ public class SKReferenceHolder : MonoBehaviour
public SKDragSpawner skDragSpawnerValue;
public SKDragSticker skDragStickerValue;

[Header("TMPro")]
[SKFolder("TMPro")]
public TMP_Text tmpTextValue;
public TMP_InputField tmpInputFieldValue;
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/SKCell/Common/SKSceneManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public class SKSceneManager : MonoSingleton<SKSceneManager>
private static AsyncOperation async = null;
private static float actualAsyncProgress = 0;

[Header("Async Settings")]
[SKFolder("Async Settings")]
public float asyncLoadLag = 3f;
public float asyncAfterFullLag = 1.5f;
public float asyncLagLowerThreshold = 0.5f, asyncLagUpperThreshold = 0.8f;

[Header("Async Events")]
[SKFolder("Async Events")]
public UnityEvent onStartLoad;
public UnityEvent onLoadingSceneLoaded,onNextSceneLoaded, onLoadingBarFull, onAwake;

Expand Down
2 changes: 1 addition & 1 deletion Assets/SKCell/Core/SKCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace SKCell
[AddComponentMenu("SKCell/SKCore")]
public sealed class SKCore : MonoSingleton<SKCore>
{
public const string SKCELL_VERSION = "v0.12.3";
public const string SKCELL_VERSION = "v0.13.2";

public static Action Awake000 = new Action(EmptyAction), Awake100 = new Action(EmptyAction),
Start000 = new Action(EmptyAction), Start100 = new Action(EmptyAction), Start200 = new Action(EmptyAction),
Expand Down
13 changes: 10 additions & 3 deletions Assets/SKCell/Editor/SKCoreEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ public class SKCoreEditor : Editor
{
public override void OnInspectorGUI()
{
GUI.DrawTexture(new Rect(new Vector2(10, 0), new Vector2(128, 64)), SKAssetLibrary.Texture_Logo);
GUI.skin.label.fontSize = 12;
Rect entireRect = EditorGUILayout.GetControlRect();
entireRect.x -= 20;
entireRect.y -= 5;
entireRect.width = 1000;
entireRect.height = 70;
EditorGUI.DrawRect(entireRect, new Color(.15f, .15f, .15f));
GUI.DrawTexture(new Rect(new Vector2(10, 0), new Vector2(450, 64)), SKAssetLibrary.Texture_Logo);
GUILayout.Space(57);
EditorGUILayout.BeginHorizontal();
GUILayout.Label("Utility Set "+SKCore.SKCELL_VERSION);
GUILayout.Label(""+SKCore.SKCELL_VERSION);
if (GUILayout.Button("Github"))
{
Application.OpenURL("https://github.com/Skyrim07/SKCell");
Expand All @@ -24,7 +31,7 @@ public override void OnInspectorGUI()
}
EditorGUILayout.EndHorizontal();
GUILayout.Label("by Alex Liu");
GUILayout.Space(20);
GUILayout.Space(5);
base.OnInspectorGUI();
}
}
Expand Down
9 changes: 9 additions & 0 deletions Assets/SKCell/Editor/SKFolderChangeProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,24 @@ namespace SKCell
{
public class SKFolderChangeProcessor : AssetPostprocessor
{
private static double lastChangeTime = 0;
private static readonly double debounceTime = 0.5; // 500ms debounce time

private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
if (EditorApplication.timeSinceStartup - lastChangeTime < debounceTime)
return;

lastChangeTime = EditorApplication.timeSinceStartup;

var allChangedAssets = importedAssets.Concat(deletedAssets).Concat(movedAssets);
HashSet<string> changedDirectories = new HashSet<string>();

foreach (string asset in allChangedAssets)
{
changedDirectories.Add(Path.GetDirectoryName(asset));
}

SKFolderIconEditor.UpdateFolderCache();
EditorApplication.RepaintProjectWindow();
}
Expand Down
63 changes: 56 additions & 7 deletions Assets/SKCell/Editor/SKFolderIconSetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System;

namespace SKCell
{
Expand All @@ -12,6 +14,17 @@ public class SKFolderIconEditor
private static Dictionary<string, string> folderTypeCache = new Dictionary<string, string>();
private static Dictionary<string, int> fileTypeCounts = new Dictionary<string, int>();

private static Dictionary<string, Color> folderColors = new Dictionary<string, Color>()
{
{"SKCell", new Color(1.0f, 0.9f,0.7f, 1f)},
{"Editor", new Color(0.3f, 0.65f,1.0f, 1f)},
{"Prefabs", new Color(0.6f, 0.95f,1.0f, 1f)},
{"Prefab", new Color(0.6f, 0.95f,1.0f, 1f)},
{"Resources", new Color(0.3f, 0.95f,0.4f, 1f)},
{"Scenes", new Color(0.83f, 0.72f,0.61f, 1f)},
{"TextMesh Pro", new Color(0.93f, 0.42f,0.41f, 1f)},
{"StreamingAssets", new Color(0.92f, 0.63f,0.96f, 1f)},
};
static SKFolderIconEditor()
{
EditorApplication.projectWindowItemOnGUI += OnProjectWindowItemGUI;
Expand All @@ -24,12 +37,39 @@ private static void OnProjectWindowItemGUI(string guid, Rect selectionRect)
if (string.IsNullOrEmpty(path) || !AssetDatabase.IsValidFolder(path))
return;

int fileCount = 0;
if (!folderTypeCache.TryGetValue(path, out string dominantType))
{
dominantType = DetermineDominantFileType(path);
dominantType = DetermineDominantFileType(path, out fileCount);
folderTypeCache[path] = dominantType;
}

Rect folderRect = new Rect(selectionRect);
string iconPath = "FolderIcons/folder";
if (selectionRect.width < 100)
{
folderRect.y -= 2;
folderRect.height -= 10;
foreach (var item in folderColors.Keys)
{
int index = Mathf.Max(0, path.LastIndexOf('/') + 1);
if (path.Substring(index) == item)
{
GUI.DrawTexture(folderRect, SKAssetLibrary.LoadTexture(iconPath), ScaleMode.ScaleToFit, true, 0, folderColors[item], 0, 0);
}
}
folderRect = new Rect(selectionRect);
Vector2 ocenter = folderRect.center;
folderRect.width *= 1.2f;
folderRect.height *= 1.0f;
folderRect.center = ocenter;
folderRect.y += folderRect.width * .08f;

bool isSelected = Selection.assetGUIDs.Contains(guid);
Color col = isSelected ? new Color(1, 1, 1, .06f) : new Color(0, 0, 0, .00f);
GUI.DrawTexture(folderRect, SKAssetLibrary.LoadTexture("sq"), ScaleMode.ScaleToFit, true, 0, col, 0, 5);
}

Texture iconTexture = dominantType == "other" ? null : SKAssetLibrary.LoadTexture($"FolderIcons/{dominantType}");
if (iconTexture)
{
Expand All @@ -42,13 +82,21 @@ private static void OnProjectWindowItemGUI(string guid, Rect selectionRect)
}
}

private static string DetermineDominantFileType(string folderPath)
private static string DetermineDominantFileType(string folderPath, out int fileCount)
{
fileTypeCounts.Clear();
int count = 0;
fileCount = 0;
if (folderPath.EndsWith("Editor"))
{
return "settings";
}
if (folderPath.EndsWith("Assets"))
{
return "other";
}
foreach (var file in Directory.GetFiles(folderPath, "*", SearchOption.AllDirectories))
{
count++;
fileCount++;
string ext = Path.GetExtension(file).ToLower();
switch (ext)
{
Expand Down Expand Up @@ -88,6 +136,7 @@ private static string DetermineDominantFileType(string folderPath)
IncrementFileType("font");
break;
case ".shader":
case ".cginc":
IncrementFileType("shader");
break;
case ".renderTexture":
Expand All @@ -110,7 +159,6 @@ private static string DetermineDominantFileType(string folderPath)
}
}
var dominantEntry = fileTypeCounts.OrderByDescending(kvp => kvp.Value).FirstOrDefault();
// int halfCount = count / 4 - 1;
return dominantEntry.Key ?? "other";
}

Expand All @@ -125,11 +173,12 @@ private static void IncrementFileType(string fileType)

[MenuItem("SKCell/Tools/Update Folder Icons Cache")]
public static void UpdateFolderCache()
{
{
int count=0;
folderTypeCache.Clear();
foreach (var folder in Directory.GetDirectories("Assets", "*", SearchOption.AllDirectories))
{
folderTypeCache[folder] = DetermineDominantFileType(folder);
folderTypeCache[folder] = DetermineDominantFileType(folder,out count );
}
}
}
Expand Down
29 changes: 18 additions & 11 deletions Assets/SKCell/Editor/SKHierarchy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ public class SKHierarchy

public static GUIContent srContent, cldContent;
public static GUIContent crossContent, resetContent;
public static Texture folderTexture;

static SKHierarchy()
{
EditorApplication.hierarchyWindowItemOnGUI += HandleHierarchyWindowItemOnGUI;

srContent = new GUIContent(SKAssetLibrary.LoadTexture($"ObjectIcons/obj_icon_7"));
cldContent = new GUIContent(SKAssetLibrary.LoadTexture($"ObjectIcons/obj_icon_11"));
folderTexture = SKAssetLibrary.LoadTexture($"ObjectIcons/obj_icon_1");
crossContent = new GUIContent(SKAssetLibrary.LoadTexture($"cross_1"));
resetContent = new GUIContent(SKAssetLibrary.LoadTexture($"return"));

Expand Down Expand Up @@ -74,8 +76,6 @@ static SKHierarchy()

private static void HandleHierarchyWindowItemOnGUI(int instanceID, Rect selectionRect)
{

FontStyle styleFont = FontStyle.Normal;
GameObject _object = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
GameObject obj = _object as GameObject;
//separators
Expand Down Expand Up @@ -163,18 +163,25 @@ private static void HandleHierarchyWindowItemOnGUI(int instanceID, Rect selectio
Rect iconRect = new Rect(selectionRect);
iconRect.xMin -= 0;
iconRect.xMax = iconRect.xMin + 16;
col = new Color(.25f,.25f,.25f);
col = Selection.activeObject == obj?new Color(.17f,.35f,.6f): new Color(.25f,.25f,.25f);
EditorGUI.DrawRect(iconRect, col);
GUI.DrawTexture(iconRect, GetHierarchyIcon(obj));

if(GUI.Button(iconRect,"", transparentButtonStyle))
if (!isSeparator)
{
Vector2 screenMousePosition = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);
float differenceY = screenMousePosition.y - Event.current.mousePosition.y;
float iconScreenY = iconRect.y + differenceY;
Vector2 windowPosition = new Vector2(iconRect.x + 30, iconScreenY + 16);
ObjectIconPopup.ShowWindow(windowPosition, obj);
GUI.DrawTexture(iconRect, GetHierarchyIcon(obj));

if (GUI.Button(iconRect, "", transparentButtonStyle))
{
Vector2 screenMousePosition = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);
float differenceY = screenMousePosition.y - Event.current.mousePosition.y;
float iconScreenY = iconRect.y + differenceY;
Vector2 windowPosition = new Vector2(iconRect.x + 30, iconScreenY + 16);
ObjectIconPopup.ShowWindow(windowPosition, obj);

}
}
else
{
GUI.DrawTexture(iconRect, folderTexture);
}

}
Expand Down
1 change: 1 addition & 0 deletions Assets/SKCell/Editor/SKSceneEditorView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ static void OnSceneGUI(SceneView sceneView)
{
ToggleObjectCount();
}

EditorGUILayout.EndHorizontal();
GUI.skin.label.fontSize = 14;
GUI.skin.label.alignment = TextAnchor.UpperLeft;
Expand Down
2 changes: 1 addition & 1 deletion Assets/SKCell/Effects/SKImageEffects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SKImageEffects : PostEffectsBase
[Range(-2f, 2f)]
public float value = .5f;

[Header("Dissolve")]
[SKFolder("Dissolve")]
public Texture dissolve_NoiseTex;
public Vector4 dissolve_st = new Vector4(1,1,0,0);

Expand Down
9 changes: 6 additions & 3 deletions Assets/SKCell/Effects/SKLineAnim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ namespace SKCell
[ExecuteInEditMode]
public class SKLineAnim : PostEffectsBase
{
public float _Speed = 1.0f, _Amplitude = 1.0f, _Frequency = 1.0f, _Thickness = 0.2f, _Phase, _Length = 1.0f;

public Color _BaseColor = Color.white, _TipColor = Color.white, _Color = Color.white;
[SKFolder("Attributes")]
public float _Speed = 1.0f;
public float _Amplitude = 1.0f, _Frequency = 1.0f, _Thickness = 0.2f, _Phase, _Length = 1.0f;
[SKFolder("Colors")]
public Color _BaseColor = Color.white;
public Color _TipColor = Color.white, _Color = Color.white;

#region References
private SpriteRenderer sr;
Expand Down
Loading

0 comments on commit 1a1b004

Please sign in to comment.