Initial Commit

This commit is contained in:
jellejurre
2025-07-19 01:03:02 +02:00
commit e7904e3140
304 changed files with 22521 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,76 @@
using UnityEngine;
using UnityEditor;
using System.Linq;
//Made by Dreadrith#3238
//Discord: https://discord.gg/ZsPfrGn
//Github: https://github.com/Dreadrith/DreadScripts
//Gumroad: https://gumroad.com/dreadrith
//Ko-fi: https://ko-fi.com/dreadrith
namespace DreadScripts.SelectionHelper
{
[System.Serializable]
public class SaveSelection : ScriptableObject
{
[SerializeReference]
public Object[] oldSelection;
public string[] s ={"Boi","Huh"};
[MenuItem("Assets/Selection Helper/Save Selection")]
[MenuItem("GameObject/Selection Helper/Save\\Load/Save Selection", false, 0)]
static void SaveSelected()
{
instance.oldSelection = Selection.objects;
Save();
}
[MenuItem("Assets/Selection Helper/Load Selection")]
[MenuItem("GameObject/Selection Helper/Save\\Load/Load Selection", false, 1)]
static void LoadSelected()
{
if (instance.oldSelection != null)
Selection.objects = Selection.objects.Concat(instance.oldSelection).ToArray();
}
private static SaveSelection _instance;
private static SaveSelection instance => _instance ? _instance : GetInstance();
public static string folderPath = "DreadScripts/Saved Data/SaveSelection";
private static string SavePath => folderPath + "/SaveSelectionData.txt";
public static SaveSelection GetInstance()
{
if (_instance == null && Exists())
{
_instance = CreateInstance<SaveSelection>();
using (System.IO.StreamReader reader = new System.IO.StreamReader(SavePath))
JsonUtility.FromJsonOverwrite(reader.ReadToEnd(),_instance);
}
if (_instance == null)
{
_instance = CreateInstance<SaveSelection>();
string directoryPath = System.IO.Path.GetDirectoryName(SavePath);
if (!System.IO.Directory.Exists(directoryPath))
System.IO.Directory.CreateDirectory(directoryPath);
string json = JsonUtility.ToJson(_instance);
using (System.IO.StreamWriter writer = System.IO.File.CreateText(SavePath))
writer.Write(json);
}
return _instance;
}
public static void Save()
{
string json = EditorJsonUtility.ToJson(_instance);
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(SavePath))
writer.Write(json);
}
public static bool Exists()
{
return System.IO.File.Exists(SavePath);
}
}
}

View File

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

View File

@@ -0,0 +1,294 @@
using UnityEditor;
using UnityEngine;
using System.Linq;
using System.Collections.Generic;
//By Dreadrith#3238
//https://discord.gg/ZsPfrGn
//Github: https://github.com/Dreadrith/DreadScripts
//Gumroad: https://gumroad.com/dreadrith
namespace DreadScripts.SelectionHelper
{
public class SceneObjectSelector : EditorWindow
{
#region Pref Keys
public const string PREF_PREFIX = "DS_SelectionHelperData_";
public static readonly string PREF_ONCOLOR = $"{PREF_PREFIX}SelectedColor";
public static readonly string PREF_OFFCOLOR = $"{PREF_PREFIX}DeselectedColor";
public static readonly string PREF_MINSIZE = $"{PREF_PREFIX}MinSize";
public static readonly string PREF_MAXSIZE = $"{PREF_PREFIX}MaxSize";
public static readonly string PREF_SIZE = $"{PREF_PREFIX}Size";
public static readonly string PREF_HUMANOID = $"{PREF_PREFIX}OnlyHumanoid";
public static void PrefSetColor(string key, Color value)
{
PlayerPrefs.SetFloat($"{key}R", value.r);
PlayerPrefs.SetFloat($"{key}G", value.g);
PlayerPrefs.SetFloat($"{key}B", value.b);
}
public static Color PrefGetColor(string key, Color defaultColor) => new Color(
PlayerPrefs.GetFloat($"{key}R", defaultColor.r),
PlayerPrefs.GetFloat($"{key}G", defaultColor.g),
PlayerPrefs.GetFloat($"{key}B", defaultColor.b));
public static void PrefSetBool(string key, bool value) => PlayerPrefs.SetInt(key, value ? 1 : 0);
public static bool PrefGetBool(string key, bool defaultValue) => PlayerPrefs.GetInt(key, defaultValue ? 1 : 0) == 1;
#endregion
[InitializeOnLoadMethod]
public static void LoadSettings()
{
OnColor = PrefGetColor(PREF_ONCOLOR, new Color(0.4f, 0.85f, 0.65f));
OffColor = PrefGetColor(PREF_OFFCOLOR, new Color(0.8f, 0.15f, 0.35f));
minHandleSize = PlayerPrefs.GetFloat(PREF_MINSIZE, 0.005f);
maxHandleSize = PlayerPrefs.GetFloat(PREF_MAXSIZE, 0.04f);
handleSize = PlayerPrefs.GetFloat(PREF_SIZE, 0.00525f);
onlyHumanoid = PrefGetBool(PREF_HUMANOID, false);
SceneView.duringSceneGui -= OnScene;
SceneView.duringSceneGui += OnScene;
Selection.selectionChanged -= OnSelectionChange;
Selection.selectionChanged += OnSelectionChange;
}
public static void SaveSettings()
{
PrefSetColor(PREF_ONCOLOR, OnColor);
PrefSetColor(PREF_OFFCOLOR, OffColor);
PlayerPrefs.SetFloat(PREF_MINSIZE, minHandleSize);
PlayerPrefs.SetFloat(PREF_MAXSIZE, maxHandleSize);
PlayerPrefs.SetFloat(PREF_SIZE, handleSize);
PrefSetBool(PREF_HUMANOID, onlyHumanoid);
SceneView.RepaintAll();
}
public static void Disable()
{
SceneView.duringSceneGui -= OnScene;
Selection.selectionChanged -= OnSelectionChange;
}
[MenuItem("DreadTools/Scripts Settings/Scene Object Selector")]
public static void showWindow()
{
GetWindow<SceneObjectSelector>("Scene Selector Settings");
}
private static bool selecting;
private static bool onlyHumanoid;
private static float handleSize, minHandleSize, maxHandleSize;
private static Transform[] sceneObjects;
private static bool ignoreDBones = true, includeRoots = true;
private static bool hasDbones = (null != System.Type.GetType("DynamicBone"));
private static bool[] bitmask;
private static Color OnColor;
private static Color OffColor;
private static void OnScene(SceneView sceneview)
{
Handles.BeginGUI();
GUILayout.Space(20);
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button(EditorGUIUtility.IconContent("CapsuleCollider2D Icon"), GUIStyle.none, GUILayout.Width(20), GUILayout.Height(20)))
{
Event e = Event.current;
if (e.button == 0)
{
selecting = !selecting;
if (selecting)
{
if (!onlyHumanoid)
{
sceneObjects = FindObjectsOfType<Transform>();
if (hasDbones && ignoreDBones)
{
System.Type dboneType = System.Type.GetType("DynamicBone");
List<Transform> dbones = new List<Transform>();
Object[] dboneScripts = FindObjectsOfType(dboneType);
foreach (Object b in dboneScripts)
{
SerializedObject sb = new SerializedObject(b);
List<Transform> exclusionList = new List<Transform>();
SerializedProperty excProp = sb.FindProperty("m_Exclusions");
for (int i = 0; i < excProp.arraySize; i++)
exclusionList.Add((Transform) excProp.GetArrayElementAtIndex(i).objectReferenceValue);
GetBoneChildren(dbones, exclusionList, (Transform) sb.FindProperty("m_Root").objectReferenceValue, includeRoots);
}
sceneObjects = sceneObjects.Except(dbones).ToArray();
}
}
else
{
var list = new List<Transform>();
foreach (var a in FindObjectsOfType<Animator>().Where(a => a.isHuman && a.avatar))
{
for (int i = 0; i < 55; i++)
{
var t = a.GetBoneTransform((HumanBodyBones) i);
if (t) list.Add(t);
}
}
sceneObjects = list.ToArray();
}
refreshBitMask();
}
}
if (e.button == 1)
{
GetWindow<SceneObjectSelector>(false, "Scene Selector Settings", true);
}
}
EditorGUILayout.EndHorizontal();
if (selecting)
{
//a
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
EditorGUI.BeginChangeCheck();
handleSize = GUILayout.VerticalSlider(handleSize, maxHandleSize, minHandleSize, GUILayout.Height(50), GUILayout.Width(15));
if (EditorGUI.EndChangeCheck())
SaveSettings();
GUILayout.Space(1);
EditorGUILayout.EndHorizontal();
}
Handles.EndGUI();
if (selecting)
{
if (sceneObjects.Length > 0)
{
for (int i = 0; i < sceneObjects.Length; i++)
{
if (!sceneObjects[i])
continue;
int controlID = sceneObjects[i].GetHashCode();
Event e = Event.current;
if (bitmask[i])
Handles.color = OnColor;
else
Handles.color = OffColor;
Handles.SphereHandleCap(controlID, sceneObjects[i].position, Quaternion.identity, handleSize, EventType.Repaint);
switch (e.GetTypeForControl(controlID))
{
case EventType.MouseDown:
if (HandleUtility.nearestControl == controlID && e.button == 0)
{
if (e.control)
{
if (!Selection.objects.Contains(sceneObjects[i].gameObject))
{
Selection.objects = Selection.objects.Concat(new GameObject[] { sceneObjects[i].gameObject }).ToArray();
}
else
{
Selection.objects = Selection.objects.Except(new GameObject[] { sceneObjects[i].gameObject }).ToArray();
}
}
else
{
Selection.activeObject = sceneObjects[i].gameObject;
}
e.Use();
}
break;
case EventType.Layout:
float distance = HandleUtility.DistanceToCircle(sceneObjects[i].position, handleSize / 2f);
HandleUtility.AddControl(controlID, distance);
break;
}
}
}
}
}
private static void GetBoneChildren(List<Transform> dbones, List<Transform> exclusionList, Transform parent, bool first = false)
{
if (exclusionList.Contains(parent)) return;
if (!first) dbones.Add(parent);
for (int i = 0; i < parent.childCount; i++)
GetBoneChildren(dbones, exclusionList, parent.GetChild(i));
}
private void OnGUI()
{
EditorGUI.BeginChangeCheck();
using (new GUILayout.HorizontalScope())
{
EditorGUIUtility.labelWidth = 20;
EditorGUILayout.LabelField("Handle Size");
minHandleSize = EditorGUILayout.FloatField(minHandleSize, GUILayout.Width(40));
handleSize = GUILayout.HorizontalSlider(handleSize, minHandleSize, maxHandleSize);
maxHandleSize = EditorGUILayout.FloatField(maxHandleSize, GUILayout.Width(40));
EditorGUIUtility.labelWidth = 0;
}
OnColor = EditorGUILayout.ColorField("Selected", OnColor);
OffColor = EditorGUILayout.ColorField("Deselected", OffColor);
using (new GUILayout.HorizontalScope())
{
EditorGUIUtility.labelWidth = 70;
onlyHumanoid = EditorGUILayout.ToggleLeft("Only Humanoid", onlyHumanoid);
if (hasDbones)
{
ignoreDBones = EditorGUILayout.ToggleLeft("Ignore D-Bones", ignoreDBones);
includeRoots = EditorGUILayout.ToggleLeft("Include D-Bone Roots", includeRoots);
}
}
if (EditorGUI.EndChangeCheck())
SaveSettings();
EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider);
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (GUILayout.Button("Made by Dreadrith#3238", "boldlabel"))
Application.OpenURL("https://github.com/Dreadrith/DreadScripts");
}
}
private static void OnSelectionChange()
{
if (selecting) refreshBitMask();
}
private static void refreshBitMask()
{
bitmask = new bool[sceneObjects.Length];
for (int i = 0; i < sceneObjects.Length; i++)
{
if (!sceneObjects[i])
{
sceneObjects = sceneObjects.Except(new Transform[] { sceneObjects[i] }).ToArray();
refreshBitMask();
break;
}
if (Selection.objects.Contains(sceneObjects[i].gameObject))
bitmask[i] = true;
else
bitmask[i] = false;
}
}
}
}

View File

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

View File

@@ -0,0 +1,91 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Linq;
namespace DreadScripts.SelectionHelper
{
public class SelectionHelper
{
//By Dreadrith#3238
//Server: https://discord.gg/ZsPfrGn
//Github: https://github.com/Dreadrith/DreadScripts
//Gumroad: https://gumroad.com/dreadrith
public static System.Type myCurrentType = System.Type.GetType(SessionState.GetString("SelectionHelperSelectType", ""));
[MenuItem("CONTEXT/Component/[SH] Choose Type", false, 900)]
static void selectType(MenuCommand selected)
{
myCurrentType = selected.context.GetType();
SessionState.SetString("SelectionHelperSelectType", myCurrentType.AssemblyQualifiedName);
}
[MenuItem("GameObject/Selection Helper/Select Immediate Children", false, 50)]
static void selectImmediate(MenuCommand selected)
{
Transform[] obj = Selection.GetFiltered<Transform>(SelectionMode.Editable);
if (obj.Length == 0)
{
Debug.Log("[SH] No GameObject was selected");
return;
}
List<GameObject> newSelection = new List<GameObject>();
for (int i = 0; i < obj.Length; i++)
{
for (int j = 0; j < obj[i].childCount; j++)
{
newSelection.Add(obj[i].GetChild(j).gameObject);
}
}
Selection.objects = Selection.objects.Concat(newSelection).ToArray();
}
[MenuItem("GameObject/Selection Helper/By Type/Filter", false, -50)]
static void selectSelectedType()
{
Selection.objects = Selection.GetFiltered(myCurrentType, SelectionMode.Editable);
List<GameObject> newSelection = new List<GameObject>();
for (int i = 0; i < Selection.objects.Length; i++)
{
newSelection.Add(((Component)Selection.objects[i]).gameObject);
}
Selection.objects = newSelection.ToArray();
}
[MenuItem("GameObject/Selection Helper/By Type/Children", false, -51)]
static void selectChildrenType(MenuCommand selected)
{
selectByType(selected, true);
}
[MenuItem("GameObject/Selection Helper/By Type/Parents", false, -52)]
static void selectParentsType(MenuCommand selected)
{
selectByType(selected, false);
}
static void selectByType(MenuCommand selected, bool child)
{
if (myCurrentType == null)
{
Debug.Log("[SH] No Component Type Chosen");
return;
}
if (!selected.context)
{
Debug.Log("[SH] No GameObject was selected");
return;
}
GameObject[] objs;
if (child)
objs = ((GameObject)selected.context).GetComponentsInChildren(myCurrentType, true).Select(c => c.gameObject).ToArray();
else
objs = ((GameObject)selected.context).GetComponentsInParent(myCurrentType, true).Select(c => c.gameObject).ToArray();
Selection.objects = objs;
}
}
}

View File

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

View File

@@ -0,0 +1,15 @@
{
"name": "com.dreadscripts.selectionhelper",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2816fbc8c0aecd44eb2bcfbd149155be
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Dreadrith
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b96a03a8521c0bc46818b2e3a1e973a8
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

22
SelectionHelper/README.md Normal file
View File

@@ -0,0 +1,22 @@
# SelectionHelper
Unity Editor package to make selecting certain objects easier and less tedious
<a href="https://vpm.dreadscripts.com/">Get it from the VCC listing!</a>
SelectionHelper:
----------------
- Go to a Component on an object and Right Click > [SH] Choose Type. Right Click on a GameObject, Selection Helper > By Type > Children, Parents, or Filter Current Selection.
- Adds Selection Helper > Select Immediate Children, to GameObjects, to Select the next level of Children of currently selected GameObjects
![Type Object Selector](https://raw.githubusercontent.com/Dreadrith/SelectionHelper/main/com.dreadscripts.selectionhelper/media~/TOS.gif)
SceneObjectSelector:
--------------------
Adds a small button to the top right of the Scene view. When clicked and enabled, will show a resizable sphere on each enabled object. This is useful for quickly selecting armature bones or managing empty objects.
Right click the new button to open its settings window. Automatically ignores Dynamic Bones by default.
![Scene Object Selector](https://raw.githubusercontent.com/Dreadrith/SelectionHelper/main/com.dreadscripts.selectionhelper/media~/SOS.gif)
SaveSelection:
--------------
Adds Save\Load to Selection Helper, allows you to Save what objects were selected, and load them when needed. Loading combines current selection with loaded selection.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 73637a1f995818c4695a9de50d48ac2f
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
{
"name": "com.dreadscripts.selectionhelper",
"displayName": "DreadScripts - Selection Helper",
"version": "1.2.4",
"unity": "2019.4",
"license": "MIT",
"description": "Unity Editor package to make selecting certain objects easier and less tedious",
"keywords": [
"Dreadrith",
"DreadScripts",
"DreadTools",
"Editor",
"Utility",
"Selection"
],
"author": {
"name": "Dreadrith",
"email": "dreadscripts@gmail.com",
"url": "https://github.com/Dreadrith"
},
"legacyFolders": {
"Assets\\DreadScripts\\Selection Helper": "6ec3e159e94175241a20166127b7da81",
"Assets\\DreadScripts\\SelectionHelper": "e0c37a2eebed7f54eb05af2439a04f27"
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dccf082c009067847b60a2b9fa931dd8
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: