FX
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace ETFXPEL
|
||||
{
|
||||
|
||||
public enum ButtonTypes {
|
||||
NotDefined,
|
||||
Previous,
|
||||
Next
|
||||
}
|
||||
|
||||
public class PEButtonScript : MonoBehaviour, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler {
|
||||
#pragma warning disable 414
|
||||
private Button myButton;
|
||||
#pragma warning disable 414
|
||||
public ButtonTypes ButtonType = ButtonTypes.NotDefined;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
myButton = gameObject.GetComponent<Button> ();
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData) {
|
||||
// Used for Tooltip
|
||||
UICanvasManager.GlobalAccess.MouseOverButton = true;
|
||||
UICanvasManager.GlobalAccess.UpdateToolTip (ButtonType);
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData) {
|
||||
// Used for Tooltip
|
||||
UICanvasManager.GlobalAccess.MouseOverButton = false;
|
||||
UICanvasManager.GlobalAccess.ClearToolTip ();
|
||||
}
|
||||
|
||||
public void OnButtonClicked () {
|
||||
// Button Click Actions
|
||||
UICanvasManager.GlobalAccess.UIButtonClick(ButtonType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4eed3eee8b1748946ab71bf4a26ce94c
|
||||
timeCreated: 1454422495
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,120 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ETFXPEL
|
||||
{
|
||||
|
||||
public class ParticleEffectsLibrary : MonoBehaviour {
|
||||
public static ParticleEffectsLibrary GlobalAccess;
|
||||
void Awake () {
|
||||
GlobalAccess = this;
|
||||
|
||||
currentActivePEList = new List<Transform> ();
|
||||
|
||||
TotalEffects = ParticleEffectPrefabs.Length;
|
||||
|
||||
CurrentParticleEffectNum = 1;
|
||||
|
||||
// Warn About Lengths of Arrays not matching
|
||||
if (ParticleEffectSpawnOffsets.Length != TotalEffects) {
|
||||
Debug.LogError ("ParticleEffectsLibrary-ParticleEffectSpawnOffset: Not all arrays match length, double check counts.");
|
||||
}
|
||||
if (ParticleEffectPrefabs.Length != TotalEffects) {
|
||||
Debug.LogError ("ParticleEffectsLibrary-ParticleEffectPrefabs: Not all arrays match length, double check counts.");
|
||||
}
|
||||
|
||||
// Setup Starting PE Name String
|
||||
effectNameString = ParticleEffectPrefabs [CurrentParticleEffectIndex].name + " (" + CurrentParticleEffectNum.ToString() + " of " + TotalEffects.ToString() + ")";
|
||||
}
|
||||
|
||||
// Stores total number of effects in arrays - NOTE: All Arrays must match length.
|
||||
public int TotalEffects = 0;
|
||||
public int CurrentParticleEffectIndex = 0;
|
||||
public int CurrentParticleEffectNum = 0;
|
||||
// public string[] ParticleEffectDisplayNames;
|
||||
public Vector3[] ParticleEffectSpawnOffsets;
|
||||
// How long until Particle Effect is Destroyed - 0 = never
|
||||
public float[] ParticleEffectLifetimes;
|
||||
public GameObject[] ParticleEffectPrefabs;
|
||||
|
||||
// Storing for deleting if looping particle effect
|
||||
#pragma warning disable 414
|
||||
private string effectNameString = "";
|
||||
#pragma warning disable 414
|
||||
private List<Transform> currentActivePEList;
|
||||
|
||||
void Start () {
|
||||
}
|
||||
|
||||
public string GetCurrentPENameString() {
|
||||
return ParticleEffectPrefabs [CurrentParticleEffectIndex].name + " (" + CurrentParticleEffectNum.ToString() + " of " + TotalEffects.ToString() + ")";
|
||||
}
|
||||
|
||||
public void PreviousParticleEffect() {
|
||||
// Destroy Looping Particle Effects
|
||||
if (ParticleEffectLifetimes [CurrentParticleEffectIndex] == 0) {
|
||||
if (currentActivePEList.Count > 0) {
|
||||
for (int i = 0; i < currentActivePEList.Count; i++) {
|
||||
if (currentActivePEList [i] != null) {
|
||||
Destroy (currentActivePEList [i].gameObject);
|
||||
}
|
||||
}
|
||||
currentActivePEList.Clear ();
|
||||
}
|
||||
}
|
||||
|
||||
// Select Previous Particle Effect
|
||||
if (CurrentParticleEffectIndex > 0) {
|
||||
CurrentParticleEffectIndex -= 1;
|
||||
} else {
|
||||
CurrentParticleEffectIndex = TotalEffects - 1;
|
||||
}
|
||||
CurrentParticleEffectNum = CurrentParticleEffectIndex + 1;
|
||||
|
||||
// Update PE Name String
|
||||
effectNameString = ParticleEffectPrefabs [CurrentParticleEffectIndex].name + " (" + CurrentParticleEffectNum.ToString() + " of " + TotalEffects.ToString() + ")";
|
||||
}
|
||||
public void NextParticleEffect() {
|
||||
// Destroy Looping Particle Effects
|
||||
if (ParticleEffectLifetimes [CurrentParticleEffectIndex] == 0) {
|
||||
if (currentActivePEList.Count > 0) {
|
||||
for (int i = 0; i < currentActivePEList.Count; i++) {
|
||||
if (currentActivePEList [i] != null) {
|
||||
Destroy (currentActivePEList [i].gameObject);
|
||||
}
|
||||
}
|
||||
currentActivePEList.Clear ();
|
||||
}
|
||||
}
|
||||
|
||||
// Select Next Particle Effect
|
||||
if (CurrentParticleEffectIndex < TotalEffects - 1) {
|
||||
CurrentParticleEffectIndex += 1;
|
||||
} else {
|
||||
CurrentParticleEffectIndex = 0;
|
||||
}
|
||||
CurrentParticleEffectNum = CurrentParticleEffectIndex + 1;
|
||||
|
||||
// Update PE Name String
|
||||
effectNameString = ParticleEffectPrefabs [CurrentParticleEffectIndex].name + " (" + CurrentParticleEffectNum.ToString() + " of " + TotalEffects.ToString() + ")";
|
||||
}
|
||||
|
||||
private Vector3 spawnPosition = Vector3.zero;
|
||||
public void SpawnParticleEffect(Vector3 positionInWorldToSpawn) {
|
||||
// Spawn Currently Selected Particle Effect
|
||||
spawnPosition = positionInWorldToSpawn + ParticleEffectSpawnOffsets[CurrentParticleEffectIndex];
|
||||
GameObject newParticleEffect = GameObject.Instantiate(ParticleEffectPrefabs[CurrentParticleEffectIndex], spawnPosition, ParticleEffectPrefabs[CurrentParticleEffectIndex].transform.rotation) as GameObject;
|
||||
newParticleEffect.name = "PE_" + ParticleEffectPrefabs[CurrentParticleEffectIndex];
|
||||
// Store Looping Particle Effects Systems
|
||||
if (ParticleEffectLifetimes [CurrentParticleEffectIndex] == 0) {
|
||||
currentActivePEList.Add (newParticleEffect.transform);
|
||||
}
|
||||
currentActivePEList.Add(newParticleEffect.transform);
|
||||
// Destroy Particle Effect After Lifetime expired
|
||||
if (ParticleEffectLifetimes [CurrentParticleEffectIndex] != 0) {
|
||||
Destroy(newParticleEffect, ParticleEffectLifetimes[CurrentParticleEffectIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a383f6b4f1b4ec4a9288e14968803f9
|
||||
timeCreated: 1454421017
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
102
Assets/Epic Toon FX/Demo/Scripts/VFX Library/UICanvasManager.cs
Normal file
102
Assets/Epic Toon FX/Demo/Scripts/VFX Library/UICanvasManager.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ETFXPEL
|
||||
{
|
||||
|
||||
public class UICanvasManager : MonoBehaviour {
|
||||
public static UICanvasManager GlobalAccess;
|
||||
void Awake () {
|
||||
GlobalAccess = this;
|
||||
}
|
||||
|
||||
public bool MouseOverButton = false;
|
||||
public Text PENameText;
|
||||
public Text ToolTipText;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
if (PENameText != null)
|
||||
PENameText.text = ParticleEffectsLibrary.GlobalAccess.GetCurrentPENameString();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
// Mouse Click - Check if mouse over button to prevent spawning particle effects while hovering or using UI buttons.
|
||||
if (!MouseOverButton) {
|
||||
// Left Button Click
|
||||
if (Input.GetMouseButtonUp (0)) {
|
||||
// Spawn Currently Selected Particle System
|
||||
SpawnCurrentParticleEffect();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyUp (KeyCode.A)) {
|
||||
SelectPreviousPE ();
|
||||
}
|
||||
if (Input.GetKeyUp (KeyCode.D)) {
|
||||
SelectNextPE ();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateToolTip(ButtonTypes toolTipType) {
|
||||
if (ToolTipText != null) {
|
||||
if (toolTipType == ButtonTypes.Previous) {
|
||||
ToolTipText.text = "Select Previous Particle Effect";
|
||||
}
|
||||
else if (toolTipType == ButtonTypes.Next) {
|
||||
ToolTipText.text = "Select Next Particle Effect";
|
||||
}
|
||||
}
|
||||
}
|
||||
public void ClearToolTip() {
|
||||
if (ToolTipText != null) {
|
||||
ToolTipText.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectPreviousPE() {
|
||||
// Previous
|
||||
ParticleEffectsLibrary.GlobalAccess.PreviousParticleEffect();
|
||||
if (PENameText != null)
|
||||
PENameText.text = ParticleEffectsLibrary.GlobalAccess.GetCurrentPENameString();
|
||||
}
|
||||
private void SelectNextPE() {
|
||||
// Next
|
||||
ParticleEffectsLibrary.GlobalAccess.NextParticleEffect();
|
||||
if (PENameText != null)
|
||||
PENameText.text = ParticleEffectsLibrary.GlobalAccess.GetCurrentPENameString();
|
||||
}
|
||||
|
||||
private RaycastHit rayHit;
|
||||
private void SpawnCurrentParticleEffect() {
|
||||
// Spawn Particle Effect
|
||||
Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
if (Physics.Raycast (mouseRay, out rayHit)) {
|
||||
ParticleEffectsLibrary.GlobalAccess.SpawnParticleEffect (rayHit.point);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User interfaces the button click.
|
||||
/// </summary>
|
||||
/// <param name="buttonTypeClicked">Button type clicked.</param>
|
||||
public void UIButtonClick(ButtonTypes buttonTypeClicked) {
|
||||
switch (buttonTypeClicked) {
|
||||
case ButtonTypes.Previous:
|
||||
// Select Previous Prefab
|
||||
SelectPreviousPE();
|
||||
break;
|
||||
case ButtonTypes.Next:
|
||||
// Select Next Prefab
|
||||
SelectNextPE();
|
||||
break;
|
||||
default:
|
||||
// Nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 678219500b099a742ab7e7957116755c
|
||||
timeCreated: 1454420980
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user