Initial commit
This commit is contained in:
8
Assets/UnityTechnologies/EffectExamples/Editor.meta
Normal file
8
Assets/UnityTechnologies/EffectExamples/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09099db12b18aaf408c9441debe04414
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/UnityTechnologies/EffectExamples/Shared.meta
Normal file
8
Assets/UnityTechnologies/EffectExamples/Shared.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec24b0cd9a89dca4bb79df8ce8b2fa30
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d9f9204333f4924d9acc426bfb0d283
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DecalDestroyer : MonoBehaviour {
|
||||
|
||||
public float lifeTime = 5.0f;
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
yield return new WaitForSeconds(lifeTime);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3cedb949dfc6b44aa88e1e82ba6471d
|
||||
timeCreated: 1474643541
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,86 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This simulate an extinguishable fire,
|
||||
/// </summary>
|
||||
public class ExtinguishableFire : MonoBehaviour
|
||||
{
|
||||
public ParticleSystem fireParticleSystem;
|
||||
public ParticleSystem smokeParticleSystem;
|
||||
|
||||
protected bool m_isExtinguished;
|
||||
|
||||
const float m_FireStartingTime = 2.0f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_isExtinguished = true;
|
||||
|
||||
smokeParticleSystem.Stop();
|
||||
fireParticleSystem.Stop();
|
||||
|
||||
StartCoroutine(StartingFire());
|
||||
}
|
||||
|
||||
public void Extinguish()
|
||||
{
|
||||
if (m_isExtinguished)
|
||||
return;
|
||||
|
||||
m_isExtinguished = true;
|
||||
StartCoroutine(Extinguishing());
|
||||
}
|
||||
|
||||
IEnumerator Extinguishing()
|
||||
{
|
||||
fireParticleSystem.Stop();
|
||||
smokeParticleSystem.time = 0;
|
||||
smokeParticleSystem.Play();
|
||||
|
||||
float elapsedTime = 0.0f;
|
||||
while (elapsedTime < m_FireStartingTime)
|
||||
{
|
||||
float ratio = Mathf.Max(0.0f, 1.0f - (elapsedTime / m_FireStartingTime));
|
||||
|
||||
fireParticleSystem.transform.localScale = Vector3.one * ratio;
|
||||
|
||||
yield return null;
|
||||
|
||||
elapsedTime += Time.deltaTime;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(2.0f);
|
||||
|
||||
smokeParticleSystem.Stop();
|
||||
fireParticleSystem.transform.localScale = Vector3.one;
|
||||
|
||||
yield return new WaitForSeconds(4.0f);
|
||||
|
||||
StartCoroutine(StartingFire());
|
||||
}
|
||||
|
||||
IEnumerator StartingFire()
|
||||
{
|
||||
smokeParticleSystem.Stop();
|
||||
fireParticleSystem.time = 0;
|
||||
fireParticleSystem.Play();
|
||||
|
||||
float elapsedTime = 0.0f;
|
||||
while (elapsedTime < m_FireStartingTime)
|
||||
{
|
||||
float ratio = Mathf.Min(1.0f, (elapsedTime / m_FireStartingTime));
|
||||
|
||||
fireParticleSystem.transform.localScale = Vector3.one * ratio;
|
||||
|
||||
yield return null;
|
||||
|
||||
elapsedTime += Time.deltaTime;
|
||||
}
|
||||
|
||||
fireParticleSystem.transform.localScale = Vector3.one;
|
||||
m_isExtinguished = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01d79beb4399f964ea234855d877ee52
|
||||
timeCreated: 1492521798
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class GunAim:MonoBehaviour
|
||||
{
|
||||
public int borderLeft;
|
||||
public int borderRight;
|
||||
public int borderTop;
|
||||
public int borderBottom;
|
||||
|
||||
private Camera parentCamera;
|
||||
private bool isOutOfBounds;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
parentCamera = GetComponentInParent<Camera>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float mouseX = Input.mousePosition.x;
|
||||
float mouseY = Input.mousePosition.y;
|
||||
|
||||
if (mouseX <= borderLeft || mouseX >= Screen.width - borderRight || mouseY <= borderBottom || mouseY >= Screen.height - borderTop)
|
||||
{
|
||||
isOutOfBounds = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isOutOfBounds = false;
|
||||
}
|
||||
|
||||
if (!isOutOfBounds)
|
||||
{
|
||||
transform.LookAt(parentCamera.ScreenToWorldPoint (new Vector3(mouseX, mouseY, 5.0f)));
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetIsOutOfBounds()
|
||||
{
|
||||
return isOutOfBounds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c63d71560c10e473ebc409185edd2c8c
|
||||
timeCreated: 1476376716
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class GunShoot : MonoBehaviour {
|
||||
|
||||
public float fireRate = 0.25f; // Number in seconds which controls how often the player can fire
|
||||
public float weaponRange = 20f; // Distance in Unity units over which the player can fire
|
||||
|
||||
public Transform gunEnd;
|
||||
public ParticleSystem muzzleFlash;
|
||||
public ParticleSystem cartridgeEjection;
|
||||
|
||||
public GameObject metalHitEffect;
|
||||
public GameObject sandHitEffect;
|
||||
public GameObject stoneHitEffect;
|
||||
public GameObject waterLeakEffect;
|
||||
public GameObject waterLeakExtinguishEffect;
|
||||
public GameObject[] fleshHitEffects;
|
||||
public GameObject woodHitEffect;
|
||||
|
||||
private float nextFire; // Float to store the time the player will be allowed to fire again, after firing
|
||||
private Animator anim;
|
||||
private GunAim gunAim;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
anim = GetComponent<Animator> ();
|
||||
gunAim = GetComponentInParent<GunAim>();
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
if (Input.GetButtonDown("Fire1") && Time.time > nextFire && !gunAim.GetIsOutOfBounds())
|
||||
{
|
||||
nextFire = Time.time + fireRate;
|
||||
muzzleFlash.Play();
|
||||
cartridgeEjection.Play();
|
||||
anim.SetTrigger ("Fire");
|
||||
|
||||
Vector3 rayOrigin = gunEnd.position;
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(rayOrigin, gunEnd.forward, out hit, weaponRange))
|
||||
{
|
||||
HandleHit(hit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HandleHit(RaycastHit hit)
|
||||
{
|
||||
if(hit.collider.sharedMaterial != null)
|
||||
{
|
||||
string materialName = hit.collider.sharedMaterial.name;
|
||||
|
||||
switch(materialName)
|
||||
{
|
||||
case "Metal":
|
||||
SpawnDecal(hit, metalHitEffect);
|
||||
break;
|
||||
case "Sand":
|
||||
SpawnDecal(hit, sandHitEffect);
|
||||
break;
|
||||
case "Stone":
|
||||
SpawnDecal(hit, stoneHitEffect);
|
||||
break;
|
||||
case "WaterFilled":
|
||||
SpawnDecal(hit, waterLeakEffect);
|
||||
SpawnDecal(hit, metalHitEffect);
|
||||
break;
|
||||
case "Wood":
|
||||
SpawnDecal(hit, woodHitEffect);
|
||||
break;
|
||||
case "Meat":
|
||||
SpawnDecal(hit, fleshHitEffects[Random.Range(0, fleshHitEffects.Length)]);
|
||||
break;
|
||||
case "Character":
|
||||
SpawnDecal(hit, fleshHitEffects[Random.Range(0, fleshHitEffects.Length)]);
|
||||
break;
|
||||
case "WaterFilledExtinguish":
|
||||
SpawnDecal(hit, waterLeakExtinguishEffect);
|
||||
SpawnDecal(hit, metalHitEffect);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SpawnDecal(RaycastHit hit, GameObject prefab)
|
||||
{
|
||||
GameObject spawnedDecal = GameObject.Instantiate(prefab, hit.point, Quaternion.LookRotation(hit.normal));
|
||||
spawnedDecal.transform.SetParent(hit.collider.transform);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 422d8644426474cfd8b793ce3c107314
|
||||
timeCreated: 1476377043
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// This script demonstrate how to use the particle system collision callback.
|
||||
/// The sample using it is the "Extinguish" prefab. It use a second, non displayed
|
||||
/// particle system to lighten the load of collision detection.
|
||||
/// </summary>
|
||||
public class ParticleCollision : MonoBehaviour
|
||||
{
|
||||
private List<ParticleCollisionEvent> m_CollisionEvents = new List<ParticleCollisionEvent>();
|
||||
private ParticleSystem m_ParticleSystem;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_ParticleSystem = GetComponent<ParticleSystem>();
|
||||
}
|
||||
|
||||
|
||||
private void OnParticleCollision(GameObject other)
|
||||
{
|
||||
int numCollisionEvents = m_ParticleSystem.GetCollisionEvents(other, m_CollisionEvents);
|
||||
for (int i = 0; i < numCollisionEvents; ++i)
|
||||
{
|
||||
var col = m_CollisionEvents[i].colliderComponent;
|
||||
|
||||
var fire = col.GetComponent<ExtinguishableFire>();
|
||||
if (fire != null)
|
||||
fire.Extinguish();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c111b630ead2a349b4c4cbf7a810085
|
||||
timeCreated: 1492521581
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class ParticleExamples {
|
||||
|
||||
public string title;
|
||||
[TextArea]
|
||||
public string description;
|
||||
public bool isWeaponEffect;
|
||||
public GameObject particleSystemGO;
|
||||
public Vector3 particlePosition, particleRotation;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1708b2ad8d149415d8ceffa3a0ae252f
|
||||
timeCreated: 1474535182
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ParticleMenu : MonoBehaviour {
|
||||
|
||||
// our ParticleExamples class being turned into an array of things that can be referenced
|
||||
public ParticleExamples[] particleSystems;
|
||||
|
||||
// the gun GameObject
|
||||
public GameObject gunGameObject;
|
||||
|
||||
// a private integer to store the current position in the array
|
||||
private int currentIndex;
|
||||
|
||||
// the currently shown prefab game object
|
||||
private GameObject currentGO;
|
||||
|
||||
// where to spawn prefabs
|
||||
public Transform spawnLocation;
|
||||
|
||||
// references to the UI Text components
|
||||
public Text title;
|
||||
public Text description;
|
||||
public Text navigationDetails;
|
||||
|
||||
// setting up the first menu item and resetting the currentIndex to ensure it's at zero
|
||||
void Start()
|
||||
{
|
||||
Navigate (0);
|
||||
currentIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
// our public function that gets called by our menu's buttons
|
||||
public void Navigate(int i){
|
||||
|
||||
// set the current position in the array to the next or previous position depending on whether i is -1 or 1, defined in our button event
|
||||
currentIndex = (particleSystems.Length + currentIndex + i) % particleSystems.Length;
|
||||
|
||||
// check if there is a currentGO, if there is (if its not null), then destroy it to make space for the new one..
|
||||
if(currentGO != null)
|
||||
Destroy (currentGO);
|
||||
|
||||
// ..spawn the relevant game object based on the array of potential game objects, according to the current index (position in the array)
|
||||
currentGO = Instantiate (particleSystems[currentIndex].particleSystemGO, spawnLocation.position + particleSystems[currentIndex].particlePosition, Quaternion.Euler(particleSystems[currentIndex].particleRotation)) as GameObject;
|
||||
|
||||
// only activate the gun GameObject if the current effect is a weapon effect
|
||||
gunGameObject.SetActive (particleSystems[currentIndex].isWeaponEffect);
|
||||
|
||||
// setup the UI texts according to the strings in the array
|
||||
title.text = particleSystems [currentIndex].title;
|
||||
description.text = particleSystems [currentIndex].description;
|
||||
navigationDetails.text = "" + (currentIndex+1) + " out of " + particleSystems.Length.ToString();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b87f472a8687453eac1a8091330b6d5
|
||||
timeCreated: 1474535267
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abdf400d240f6c4449278ba5933b3dec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9a4302e3942f2f46807e168616d08a2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,92 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a186f8a87ca4f4d3aa864638ad5dfb65
|
||||
timeCreated: 1484669919
|
||||
licenseType: Store
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 4
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapMode: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
- buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
- buildTarget: iPhone
|
||||
maxTextureSize: 2048
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
- buildTarget: tvOS
|
||||
maxTextureSize: 2048
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user