-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# This .gitignore file should be placed at the root of your Unity project directory | ||
# | ||
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore | ||
# | ||
/[Ll]ibrary/ | ||
/[Tt]emp/ | ||
/[Oo]bj/ | ||
/[Bb]uild/ | ||
/[Bb]uilds/ | ||
/[Ll]ogs/ | ||
/[Mm]emoryCaptures/ | ||
|
||
# Asset meta data should only be ignored when the corresponding asset is also ignored | ||
!/[Aa]ssets/**/*.meta | ||
|
||
# Uncomment this line if you wish to ignore the asset store tools plugin | ||
# /[Aa]ssets/AssetStoreTools* | ||
|
||
# Autogenerated Jetbrains Rider plugin | ||
[Aa]ssets/Plugins/Editor/JetBrains* | ||
|
||
# Visual Studio cache directory | ||
.vs/ | ||
|
||
# Gradle cache directory | ||
.gradle/ | ||
|
||
# Autogenerated VS/MD/Consulo solution and project files | ||
ExportedObj/ | ||
.consulo/ | ||
*.csproj | ||
*.unityproj | ||
*.sln | ||
*.suo | ||
*.tmp | ||
*.user | ||
*.userprefs | ||
*.pidb | ||
*.booproj | ||
*.svd | ||
*.pdb | ||
*.mdb | ||
*.opendb | ||
*.VC.db | ||
|
||
# Unity3D generated meta files | ||
*.pidb.meta | ||
*.pdb.meta | ||
*.mdb.meta | ||
|
||
# Unity3D generated file on crash reports | ||
sysinfo.txt | ||
|
||
# Builds | ||
*.apk | ||
*.unitypackage | ||
|
||
# Crashlytics generated file | ||
crashlytics-build.properties | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using MegaTools.Utils; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace MegaTools.Editor.Utils | ||
{ | ||
[CustomEditor(typeof(RigidbodyCenterOfMass))] | ||
public class RigidbodyCenterOfMassEditor : UnityEditor.Editor | ||
{ | ||
private void OnSceneGUI() | ||
{ | ||
RigidbodyCenterOfMass rb = target as RigidbodyCenterOfMass; | ||
|
||
EditorGUI.BeginChangeCheck(); | ||
|
||
Handles.color = new Color(1f, 0.18f, 0.24f, 0.5f); | ||
Handles.SphereHandleCap(0, rb.transform.TransformPoint(rb.CenterOfMass), Quaternion.identity, 0.25f, | ||
EventType.Repaint); | ||
|
||
Vector3 newTargetPosition = | ||
Handles.PositionHandle(rb.transform.TransformPoint(rb.CenterOfMass), Quaternion.identity); | ||
|
||
if (EditorGUI.EndChangeCheck()) | ||
{ | ||
Undo.RecordObject(rb, "Change Center Of Mass Position"); | ||
rb.CenterOfMass = newTargetPosition - rb.transform.position; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "RigidbodyCenterOfMassEditor.Editor", | ||
"references": [ | ||
"GUID:82f26132c37a5ed4a80fdbb22a7f013e" | ||
], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Miley Hollenberg | ||
|
||
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. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Rigidbody Center Of Mass Editor | ||
Allows you to change the center of mass of Rigidbodies within the Unity editor | ||
|
||
# Usage | ||
Add the `RigidbodyCenterOfMass` component to an object with a `Rigidbody` component (one will be created if it doesn't exist already) and modify the X,Y,Z position of the center of mass either through the inspector or the red sphere in the scene |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using UnityEngine; | ||
|
||
namespace MegaTools.Utils | ||
{ | ||
[RequireComponent(typeof(Rigidbody))] | ||
public class RigidbodyCenterOfMass : MonoBehaviour | ||
{ | ||
public Vector3 CenterOfMass = new Vector3(0, 0, 0); | ||
private Rigidbody _rb; | ||
|
||
private void Awake() | ||
{ | ||
_rb = GetComponent<Rigidbody>(); | ||
} | ||
|
||
private void Start() | ||
{ | ||
_rb.centerOfMass = CenterOfMass; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "RigidbodyCenterOfMassEditor", | ||
"references": [], | ||
"includePlatforms": [], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "io.megamiley.rigidbody-center-of-mass-editor", | ||
"version": "1.0.0", | ||
"displayName": "Rigidbody Center Of Mass Editor", | ||
"description": "Allows you to change the Center of Mass of a Rigidbody inside the editor", | ||
"unity": "2018.1", | ||
"keywords": [ | ||
"editor", | ||
"rigidbody", | ||
"center of mass" | ||
], | ||
"author": { | ||
"name": "Miley Hollenberg", | ||
"email": "[email protected]", | ||
"url": "https://github.com/MileyHollenberg/RigidbodyCenterOfMassEditor" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.