add some extra assets FX and SFX
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b164bc43b75c4bf7a5a1914a1dd507e
|
||||
folderAsset: yes
|
||||
timeCreated: 1513226830
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
using EzySlice;
|
||||
|
||||
/**
|
||||
* This is a simple Editor helper script for rapid testing/prototyping!
|
||||
*/
|
||||
[CustomEditor(typeof(ShatterExample))]
|
||||
public class ShatterExampleEditor : Editor {
|
||||
public GameObject source;
|
||||
public Material crossMat;
|
||||
public int slice;
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
ShatterExample plane = (ShatterExample)target;
|
||||
|
||||
source = (GameObject)EditorGUILayout.ObjectField(source, typeof(GameObject), true);
|
||||
|
||||
if (source == null) {
|
||||
EditorGUILayout.LabelField("Add a GameObject to Shatter.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source.activeInHierarchy) {
|
||||
EditorGUILayout.LabelField("Object is Hidden. Cannot Slice.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.GetComponent<MeshFilter>() == null) {
|
||||
EditorGUILayout.LabelField("GameObject must have a MeshFilter.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
crossMat = (Material)EditorGUILayout.ObjectField(crossMat, typeof(Material), true);
|
||||
slice = EditorGUILayout.IntSlider(slice, 1, 20);
|
||||
|
||||
if (GUILayout.Button("Shatter Object")) {
|
||||
if (plane.ShatterObject(source, slice, crossMat)) {
|
||||
source.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0bc9b3efbea340c0ae2cb00d46f9a2c
|
||||
timeCreated: 1521778957
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/EzySlice/Scripts/Editor/ShatterExampleEditor.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,68 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using EzySlice;
|
||||
|
||||
/**
|
||||
* Represents a really badly written shatter script! use for reference purposes only.
|
||||
*/
|
||||
public class RuntimeShatterExample : MonoBehaviour {
|
||||
|
||||
public GameObject objectToShatter;
|
||||
public Material crossSectionMaterial;
|
||||
|
||||
public List<GameObject> prevShatters = new List<GameObject>();
|
||||
|
||||
public GameObject[] ShatterObject(GameObject obj, Material crossSectionMaterial = null) {
|
||||
return obj.SliceInstantiate(GetRandomPlane(obj.transform.position, obj.transform.localScale),
|
||||
new TextureRegion(0.0f, 0.0f, 1.0f, 1.0f),
|
||||
crossSectionMaterial);
|
||||
}
|
||||
|
||||
public EzySlice.Plane GetRandomPlane(Vector3 positionOffset, Vector3 scaleOffset) {
|
||||
Vector3 randomPosition = Random.insideUnitSphere;
|
||||
|
||||
//randomPosition += positionOffset;
|
||||
|
||||
Vector3 randomDirection = Random.insideUnitSphere.normalized;
|
||||
|
||||
return new EzySlice.Plane(randomPosition, randomDirection);
|
||||
}
|
||||
|
||||
public void RandomShatter() {
|
||||
if (prevShatters.Count == 0) {
|
||||
GameObject[] shatters = ShatterObject(objectToShatter, crossSectionMaterial);
|
||||
|
||||
if (shatters != null && shatters.Length > 0) {
|
||||
objectToShatter.SetActive(false);
|
||||
|
||||
// add rigidbodies and colliders
|
||||
foreach (GameObject shatteredObject in shatters) {
|
||||
shatteredObject.AddComponent<MeshCollider>().convex = true;
|
||||
shatteredObject.AddComponent<Rigidbody>();
|
||||
|
||||
prevShatters.Add(shatteredObject);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise, shatter the previous shattered objects, randomly picked
|
||||
GameObject randomObject = prevShatters[Random.Range(0, prevShatters.Count - 1)];
|
||||
|
||||
GameObject[] randShatter = ShatterObject(randomObject, crossSectionMaterial);
|
||||
|
||||
if (randShatter != null && randShatter.Length > 0) {
|
||||
randomObject.SetActive(false);
|
||||
|
||||
// add rigidbodies and colliders
|
||||
foreach (GameObject shatteredObject in randShatter) {
|
||||
shatteredObject.AddComponent<MeshCollider>().convex = true;
|
||||
shatteredObject.AddComponent<Rigidbody>();
|
||||
|
||||
prevShatters.Add(shatteredObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fed9a144ebdc46bd845b2b75e2e1854
|
||||
timeCreated: 1525669637
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/EzySlice/Scripts/RuntimeShatterExample.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,56 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using EzySlice;
|
||||
|
||||
/**
|
||||
* An example fun script to show how a shatter operation can be applied to a GameObject
|
||||
* by repeatedly and randomly slicing an object
|
||||
*/
|
||||
public class ShatterExample : MonoBehaviour
|
||||
{
|
||||
|
||||
/**
|
||||
* This function will slice the provided object by the plane defined in this
|
||||
* GameObject. We use the GameObject this script is attached to define the position
|
||||
* and direction of our cutting Plane. Results are then returned to the user.
|
||||
*/
|
||||
public bool ShatterObject (GameObject obj, int iterations, Material crossSectionMaterial = null)
|
||||
{
|
||||
if (iterations > 0) {
|
||||
GameObject[] slices = obj.SliceInstantiate (GetRandomPlane (obj.transform.position, obj.transform.localScale),
|
||||
new TextureRegion (0.0f, 0.0f, 1.0f, 1.0f),
|
||||
crossSectionMaterial);
|
||||
|
||||
if (slices != null) {
|
||||
// shatter the shattered!
|
||||
for (int i = 0; i < slices.Length; i++) {
|
||||
if (ShatterObject (slices [i], iterations - 1, crossSectionMaterial)) {
|
||||
// delete the parent
|
||||
GameObject.DestroyImmediate (slices [i]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return ShatterObject (obj, iterations - 1, crossSectionMaterial);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an offset position and an offset scale, calculate a random plane
|
||||
* which can be used to randomly slice an object
|
||||
*/
|
||||
public EzySlice.Plane GetRandomPlane (Vector3 positionOffset, Vector3 scaleOffset)
|
||||
{
|
||||
Vector3 randomPosition = Random.insideUnitSphere;
|
||||
|
||||
randomPosition += positionOffset;
|
||||
|
||||
Vector3 randomDirection = Random.insideUnitSphere.normalized;
|
||||
|
||||
return new EzySlice.Plane (randomPosition, randomDirection);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b942e4ba3b5404f77bd7dfba57a9359b
|
||||
timeCreated: 1521778957
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/EzySlice/Scripts/ShatterExample.cs
|
||||
uploadId: 889948
|
||||
Reference in New Issue
Block a user