Last active
January 1, 2016 00:09
-
-
Save Arakade/8064316 to your computer and use it in GitHub Desktop.
A patch for Ultimate Game Tools' "Fracturing" Unity3D plugin that adds ability to call FracturedObject.ResetChunks() while still using lifetime timers (DieTimer). UGT: http://www.ultimategametools.com/products/fracturing/ Proposed: http://forum.unity3d.com/threads/184170-Ultimate-Fracturing-amp-Destruction-editor-extension-for-Unity-3D?p=1460344…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ru C:\Users\User\Dev\Unity3D\FracturingNoChanges\Assets\Ultimate Game Tools\Fracturing\Editor\FracturedObjectEditor.cs C:\Users\User\Dev\Unity3D\SnowFallFracturedExperiment\Assets\Ultimate Game Tools\Fracturing\Editor\FracturedObjectEditor.cs | |
--- C:\Users\User\Dev\Unity3D\FracturingNoChanges\Assets\Ultimate Game Tools\Fracturing\Editor\FracturedObjectEditor.cs Tue Dec 10 20:01:47 2013 | |
+++ C:\Users\User\Dev\Unity3D\SnowFallFracturedExperiment\Assets\Ultimate Game Tools\Fracturing\Editor\FracturedObjectEditor.cs Sat Dec 21 18:24:45 2013 | |
@@ -56,6 +56,7 @@ | |
SerializedProperty PropEventDetachedMinLifeTime; | |
SerializedProperty PropEventDetachedMaxLifeTime; | |
SerializedProperty PropEventDetachedOffscreenLifeTime; | |
+ SerializedProperty PropEventDetachedDestroyRatherThanInactivate; | |
SerializedProperty PropEventDetachedMinMass; | |
SerializedProperty PropEventDetachedMinVelocity; | |
SerializedProperty PropEventDetachedMaxSounds; | |
@@ -162,6 +163,7 @@ | |
PropEventDetachedMinLifeTime = serializedObject.FindProperty("EventDetachedMinLifeTime"); | |
PropEventDetachedMaxLifeTime = serializedObject.FindProperty("EventDetachedMaxLifeTime"); | |
PropEventDetachedOffscreenLifeTime = serializedObject.FindProperty("EventDetachedOffscreenLifeTime"); | |
+ PropEventDetachedDestroyRatherThanInactivate = serializedObject.FindProperty("EventDetachedDestroyRatherThanInactivate"); | |
PropEventDetachedMinMass = serializedObject.FindProperty("EventDetachedMinMass"); | |
PropEventDetachedMinVelocity = serializedObject.FindProperty("EventDetachedMinVelocity"); | |
PropEventDetachedMaxSounds = serializedObject.FindProperty("EventDetachedMaxSounds"); | |
@@ -468,6 +470,7 @@ | |
EditorGUILayout.PropertyField(PropEventDetachedMinLifeTime, new GUIContent("Min Chunk LifeTime", "The minimum lifetime of a free chunk. When the life of a chunk expires it will be deleted.")); | |
EditorGUILayout.PropertyField(PropEventDetachedMaxLifeTime, new GUIContent("Max Chunk LifeTime", "The maximum lifetime of a free chunk. When the life of a chunk expires it will be deleted.")); | |
EditorGUILayout.PropertyField(PropEventDetachedOffscreenLifeTime, new GUIContent("Offscreen LifeTime", "If a free chunk is outside the visible screen for more than this seconds, it will be deleted.")); | |
+ EditorGUILayout.PropertyField(PropEventDetachedDestroyRatherThanInactivate, new GUIContent("Destroy (rather than inactivate)", "Fully Destroy() chunks after their lifetime expires (false = SetActive(false)).")); | |
EditorGUILayout.PropertyField(PropEventDetachedMinMass, new GUIContent("Min Impact Mass", "The minimum mass a free chunk need to impact with in order to trigger a collision event.")); | |
EditorGUILayout.PropertyField(PropEventDetachedMinVelocity, new GUIContent("Min Impact Velocity", "The minimum velocity a free chunk need to impact with in order to trigger a collision event.")); | |
EditorGUILayout.PropertyField(PropEventDetachedMaxSounds, new GUIContent("Max Simult. Sounds", "The maximum collision sounds that will be played at the same time.")); | |
diff -ru C:\Users\User\Dev\Unity3D\FracturingNoChanges\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturedChunk.cs C:\Users\User\Dev\Unity3D\SnowFallFracturedExperiment\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturedChunk.cs | |
--- C:\Users\User\Dev\Unity3D\FracturingNoChanges\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturedChunk.cs Tue Dec 10 20:01:46 2013 | |
+++ C:\Users\User\Dev\Unity3D\SnowFallFracturedExperiment\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturedChunk.cs Sat Dec 28 18:14:10 2013 | |
@@ -103,6 +103,23 @@ | |
} | |
} | |
+ public new void Destroy(UnityEngine.Object o) { | |
+ Debug.Log(string.Format("{0} destroying {1}", this, o), this); | |
+ if (null == FracturedObjectSource || FracturedObjectSource.EventDetachedDestroyRatherThanInactivate || !(o is GameObject) || o != gameObject) | |
+ { | |
+ UnityEngine.Object.Destroy(o); | |
+ } | |
+ else | |
+ { | |
+ gameObject.SetActive(false); | |
+ DieTimer dieTimer = GetComponent<DieTimer>(); | |
+ if (null != dieTimer) | |
+ { | |
+ UnityEngine.Object.Destroy(dieTimer); // remove DieTimer before next frame | |
+ } | |
+ } | |
+ } | |
+ | |
void OnCollisionEnter(Collision collision) | |
{ | |
if(FracturedObjectSource == null || collision == null) | |
@@ -318,6 +335,17 @@ | |
ListAdjacentChunks = new List<AdjacencyInfo>(ListAdjacentChunksCopy); | |
m_fInvisibleTimer = 0.0f; | |
+ | |
+ if (!FracturedObjectSource.EventDetachedDestroyRatherThanInactivate) | |
+ { | |
+ gameObject.SetActive(true); | |
+ } | |
+ | |
+ DieTimer dieTimer = GetComponent<DieTimer>(); | |
+ if (null != dieTimer) | |
+ { | |
+ Destroy(dieTimer); | |
+ } | |
} | |
public void Impact(Vector3 v3Position, float fExplosionForce, float fRadius, bool bAlsoImpactFreeChunks) | |
diff -ru C:\Users\User\Dev\Unity3D\FracturingNoChanges\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturedObject.cs C:\Users\User\Dev\Unity3D\SnowFallFracturedExperiment\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturedObject.cs | |
--- C:\Users\User\Dev\Unity3D\FracturingNoChanges\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturedObject.cs Tue Dec 10 20:01:42 2013 | |
+++ C:\Users\User\Dev\Unity3D\SnowFallFracturedExperiment\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturedObject.cs Sat Dec 21 18:24:54 2013 | |
@@ -81,6 +81,7 @@ | |
public float EventDetachedMinLifeTime = Mathf.Infinity; | |
public float EventDetachedMaxLifeTime = Mathf.Infinity; | |
public float EventDetachedOffscreenLifeTime = Mathf.Infinity; | |
+ public bool EventDetachedDestroyRatherThanInactivate = true; | |
public float EventDetachedMinMass = 1.0f; | |
public float EventDetachedMinVelocity = 1.0f; | |
public int EventDetachedMaxSounds = 5; | |
@@ -347,6 +348,7 @@ | |
CheckDetachNonSupportedChunks(true); | |
} | |
+ SetSingleMeshVisibility(true); | |
return true; | |
} | |
diff -ru C:\Users\User\Dev\Unity3D\FracturingNoChanges\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturingUtilDieTimer.cs C:\Users\User\Dev\Unity3D\SnowFallFracturedExperiment\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturingUtilDieTimer.cs | |
--- C:\Users\User\Dev\Unity3D\FracturingNoChanges\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturingUtilDieTimer.cs Tue Dec 10 20:01:25 2013 | |
+++ C:\Users\User\Dev\Unity3D\SnowFallFracturedExperiment\Assets\Ultimate Game Tools\Fracturing\Scripts\FracturingUtilDieTimer.cs Sat Dec 28 18:13:54 2013 | |
@@ -21,7 +21,15 @@ | |
if(m_fTimer > SecondsToDie) | |
{ | |
- Destroy(gameObject); | |
+ FracturedChunk fc = GetComponent<FracturedChunk>(); | |
+ if (null != fc) | |
+ { | |
+ fc.Destroy(gameObject); | |
+ } | |
+ else | |
+ { | |
+ Destroy(gameObject); | |
+ } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment