mass, drag and useGravity to inspector

This commit is contained in:
2016-04-17 20:47:17 +06:00
parent 7c22b52489
commit 91195b66a6
9 changed files with 243 additions and 168 deletions

View File

@@ -88,6 +88,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4febe544112bb4678bdd59fa963c802d, type: 3}
m_Name:
m_EditorClassIdentifier:
_mass: 1
_drag: 0
_useGravity: 1
_isKinematic: 0
_interpolation: 0
_collisionDetectionMode: 0

View File

@@ -143,6 +143,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4febe544112bb4678bdd59fa963c802d, type: 3}
m_Name:
m_EditorClassIdentifier:
_mass: 1
_drag: 0
_useGravity: 0
_isKinematic: 1
_interpolation: 0
_collisionDetectionMode: 0

View File

@@ -157,6 +157,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4febe544112bb4678bdd59fa963c802d, type: 3}
m_Name:
m_EditorClassIdentifier:
_mass: 1
_drag: 0
_useGravity: 0
_isKinematic: 1
_interpolation: 0
_collisionDetectionMode: 0

View File

@@ -143,6 +143,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4febe544112bb4678bdd59fa963c802d, type: 3}
m_Name:
m_EditorClassIdentifier:
_mass: 1
_drag: 0
_useGravity: 0
_isKinematic: 1
_interpolation: 0
_collisionDetectionMode: 0

View File

@@ -39,7 +39,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155508}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: .0710000023, y: .238000005, z: 0}
m_LocalPosition: {x: 0.071, y: 0.238, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 483758}
@@ -68,9 +68,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9a9c584f9a39449438abc7ba59a68778, type: 3}
m_Name:
m_EditorClassIdentifier:
_mode: 0
_size: {x: .300000012, y: .100000001, z: .550000012}
_size: {x: 0.3, y: 0.1, z: 0.55}
_position: {x: 0, y: 0, z: 0}
_mode: 0
_cacheRenderers: 0
_isAlignment: 0
_isShowBounds: 0
--- !u!212 &21219938
@@ -91,14 +92,18 @@ SpriteRenderer:
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_AutoUVMaxDistance: .5
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: d2bd69190895949ba8ea55f7b6bae72b, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1

View File

@@ -39,7 +39,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 101598}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: .0489999987, y: .252999991, z: 0}
m_LocalPosition: {x: 0.049, y: 0.253, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 499162}
@@ -68,9 +68,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9a9c584f9a39449438abc7ba59a68778, type: 3}
m_Name:
m_EditorClassIdentifier:
_mode: 0
_size: {x: .300000012, y: .100000001, z: .550000012}
_size: {x: 0.3, y: 0.1, z: 0.55}
_position: {x: 0, y: 0, z: 0}
_mode: 0
_cacheRenderers: 0
_isAlignment: 0
_isShowBounds: 0
--- !u!212 &21217330
@@ -91,14 +92,18 @@ SpriteRenderer:
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_AutoUVMaxDistance: .5
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 0cb0183a69dea4a0598d497b2b61edd5, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1

View File

@@ -89,6 +89,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4febe544112bb4678bdd59fa963c802d, type: 3}
m_Name:
m_EditorClassIdentifier:
_mass: 1
_drag: 0
_useGravity: 1
_isKinematic: 0
_interpolation: 0
_collisionDetectionMode: 0

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,42 @@ namespace IsoTools {
}
}
[SerializeField]
public float _mass = 1.0f;
public float mass {
get { return _mass; }
set {
_mass = value;
if ( realRigidbody ) {
realRigidbody.mass = value;
}
}
}
[SerializeField]
public float _drag = 0.0f;
public float drag {
get { return _drag; }
set {
_drag = value;
if ( realRigidbody ) {
realRigidbody.drag = value;
}
}
}
[SerializeField]
public bool _useGravity = true;
public bool useGravity {
get { return _useGravity; }
set {
_useGravity = value;
if ( realRigidbody ) {
realRigidbody.useGravity = value;
}
}
}
[SerializeField]
public bool _isKinematic = false;
public bool isKinematic {
@@ -67,15 +103,6 @@ namespace IsoTools {
}
}
public float drag {
get { return realRigidbody ? realRigidbody.drag : 0.0f; }
set {
if ( realRigidbody ) {
realRigidbody.drag = value;
}
}
}
public Vector3 inertiaTensor {
get { return realRigidbody ? realRigidbody.inertiaTensor : Vector3.zero; }
set {
@@ -85,15 +112,6 @@ namespace IsoTools {
}
}
public float mass {
get { return realRigidbody ? realRigidbody.mass : 0.0f; }
set {
if ( realRigidbody ) {
realRigidbody.mass = value;
}
}
}
public float maxDepenetrationVelocity {
get { return realRigidbody ? realRigidbody.maxDepenetrationVelocity : 0.0f; }
set {
@@ -121,15 +139,6 @@ namespace IsoTools {
}
}
public bool useGravity {
get { return realRigidbody ? realRigidbody.useGravity : false; }
set {
if ( realRigidbody ) {
realRigidbody.useGravity = value;
}
}
}
public Vector3 velocity {
get { return realRigidbody ? realRigidbody.velocity : Vector3.zero; }
set {
@@ -258,6 +267,9 @@ namespace IsoTools {
IsoUtils.GetOrCreateComponent<IsoFakeRigidbody>(fakeObject).Init(this);
_realRigidbody = IsoUtils.GetOrCreateComponent<Rigidbody>(fakeObject);
_realRigidbody.freezeRotation = true;
_realRigidbody.mass = mass;
_realRigidbody.drag = drag;
_realRigidbody.useGravity = useGravity;
_realRigidbody.isKinematic = isKinematic;
_realRigidbody.interpolation = interpolation;
_realRigidbody.collisionDetectionMode = collisionDetectionMode;
@@ -285,6 +297,9 @@ namespace IsoTools {
#if UNITY_EDITOR
void Reset() {
mass = 1.0f;
drag = 0.0f;
useGravity = true;
isKinematic = false;
interpolation = RigidbodyInterpolation.None;
collisionDetectionMode = CollisionDetectionMode.Discrete;
@@ -293,6 +308,9 @@ namespace IsoTools {
void OnValidate() {
if ( realRigidbody ) {
realRigidbody.mass = mass;
realRigidbody.drag = drag;
realRigidbody.useGravity = useGravity;
realRigidbody.isKinematic = isKinematic;
realRigidbody.interpolation = interpolation;
realRigidbody.collisionDetectionMode = collisionDetectionMode;