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

8
AutoBounds/Editor.meta Normal file
View File

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

View File

@@ -0,0 +1,92 @@
using UnityEngine;
using UnityEditor;
//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.AutoBounds
{
public class AutoBounds
{
private const float boundsPercentIncrease = 25;
//Sets bounds to auto-calculated dimensions starting from the target
[MenuItem("DreadTools/Utility/AutoBounds/Auto")]
private static void CalculateBounds()
{
//Get Selection
GameObject go = Selection.activeGameObject;
if (!go) return;
//Check for animator and to use hips instead of target as root
//Always using target as root may make the bounds follow improperly
Animator ani = go.GetComponent<Animator>();
bool isHuman = ani && ani.avatar && ani.isHuman;
Transform rootBone = isHuman ? ani.GetBoneTransform(HumanBodyBones.Hips) ?? go.transform : go.transform;
//Get child renderers including disabled
var renderers = go.GetComponentsInChildren<SkinnedMeshRenderer>(true);
//Get Max Extent by getting the biggest dimension
//Avatars can rotate their armature around meaning this dimension can go in any direction, so reuse it for every dimension
//Probably not the best logic or calculation but it usually works
float maxExtent = 0;
foreach (var r in renderers)
{
if (!r.sharedMesh) continue;
Transform currentRootBone = r.rootBone ?? r.transform;
var currentExtent = GetMaxAxis(rootBone.InverseTransformPoint(currentRootBone.position)) + GetMaxAxis(r.sharedMesh.bounds.size);
if (maxExtent < currentExtent) maxExtent = currentExtent;
}
//If human, hips should stay the center
//Otherwise, center the bounds vertically based on current dimensions
Vector3 center = new Vector3(0, isHuman ? 0 : maxExtent / 2, 0);
//Increase area by percentage for safe measure
maxExtent *= 1 + boundsPercentIncrease / 100;
Vector3 extents = new Vector3(maxExtent, maxExtent, maxExtent);
//Set auto calculated bounds starting from target as root
SetBounds(go.transform, rootBone, new Bounds(center, extents));
}
//Sets sampled bounds from target starting from top most parent of target
[MenuItem("DreadTools/Utility/AutoBounds/Sample")]
private static void SampleBounds()
{
//Get Selection
GameObject go = Selection.activeGameObject;
if (!go) return;
//Get renderer for sampling
SkinnedMeshRenderer sampleRenderer = go.GetComponent<SkinnedMeshRenderer>();
if (!sampleRenderer)
{
Debug.LogWarning("No skinned mesh renderer on selected gameobject.");
return;
}
//Set the samples bounds start from the top most parent
SetBounds(go.transform.root, sampleRenderer.rootBone, sampleRenderer.bounds);
}
//Sets all children skinned mesh renderers of the root to the given bounds
private static void SetBounds(Transform root, Transform rootbone, Bounds myBounds)
{
foreach (var r in root.GetComponentsInChildren<SkinnedMeshRenderer>(true))
{
r.rootBone = rootbone;
r.localBounds = myBounds;
EditorUtility.SetDirty(r);
}
}
private static float GetMaxAxis(Vector3 v) => Mathf.Max(v.x, v.y, v.z);
}
}

View File

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

View File

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

View File

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

26
AutoBounds/How to use.txt Normal file
View File

@@ -0,0 +1,26 @@
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
Menu items can be found in the top left corner of the Unity Editor window
[DreadTools > Utility > AutoBounds]
===========================================================================
[Automatic]
This will set all the skinned mesh renderers of the target to the same automatically calculated bounds and sets the hip/root bone as the target.
1- Select the root of your avatar.
2- Press the menu item: [DreadTools > Utility > AutoBounds > Auto]
============================================================================
[Sample]
This will set all the skinned mesh renderers that are children to the top most parent of the target to the same bounds and root bone as the target.
1- Select the target that you want to sample from.
2- Press the menu item: [DreadTools > Utility > AutoBounds > Sample]
============================================================================

View File

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

21
AutoBounds/LICENSE Normal file
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.

7
AutoBounds/LICENSE.meta Normal file
View File

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

23
AutoBounds/README.md Normal file
View File

@@ -0,0 +1,23 @@
# AutoBounds
AutoBounds's purpose is to make easier to set the bounds of skinned mesh renderers so that they don't disappear in your peripherals especially when the avatar is not in a standing pose
# How To Use
Menu items can be found in the top left corner of the Unity Editor window
[DreadTools > Utility > AutoBounds]
## Automatic
This will set all the skinned mesh renderers of the target to the same automatically calculated bounds and sets the hip/root bone as the target.
1- Select the root of your avatar.
2- Press the menu item: [DreadTools > Utility > AutoBounds > Auto]
## Sample
This will set all the skinned mesh renderers that are children to the top most parent of the target to the same bounds and root bone as the target.
1- Select the target that you want to sample from.
2- Press the menu item: [DreadTools > Utility > AutoBounds > Sample]
### Before
[<img src="https://raw.githubusercontent.com/Dreadrith/AutoBounds/main/_media/Before.png">]()
### After
[<img src="https://raw.githubusercontent.com/Dreadrith/AutoBounds/main/_media/After.png">]()

View File

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

8
AutoBounds/_media.meta Normal file
View File

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

BIN
AutoBounds/_media/After.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

View File

@@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: b4d4eec8e21c87f47b20228e1ed0e320
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

View File

@@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: 654e762dad0af114c9f148942ba2b372
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

23
AutoBounds/package.json Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "com.dreadscripts.tool.autobounds",
"displayName": "AutoBounds",
"version": "1.0.0",
"unity": "2019.4",
"description": "Editor script to help setting the bounds of skinned mesh renderers.",
"keywords": [
"Dreadrith",
"DreadScripts",
"DreadTools",
"Editor",
"Utility",
"Renderers"
],
"author": {
"name": "Dreadrith",
"email": "dreadscripts@gmail.com",
"url": "https://github.com/Dreadrith"
},
"legacyFolders": {
"Assets\\DreadScripts\\Utility\\Editor\\AutoBounds": "97d295ac00bde904b83106bff682f8b6"
}
}

View File

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