You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-14 20:20:06 +00:00
demo: update demos
This commit is contained in:
14
Samples~/Demo/Scripts/Coffee.UIParticle.Demo.asmdef
Normal file
14
Samples~/Demo/Scripts/Coffee.UIParticle.Demo.asmdef
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "Coffee.UIParticle.Demo",
|
||||
"references": [
|
||||
"Coffee.UIParticle"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": []
|
||||
}
|
||||
7
Samples~/Demo/Scripts/Coffee.UIParticle.Demo.asmdef.meta
Normal file
7
Samples~/Demo/Scripts/Coffee.UIParticle.Demo.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a2546af409064ee88073040a7454090
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Samples~/Demo/Scripts/CopyItemOnStart.cs
Normal file
25
Samples~/Demo/Scripts/CopyItemOnStart.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions.Demo
|
||||
{
|
||||
public class CopyItemOnStart : MonoBehaviour
|
||||
{
|
||||
public GameObject origin;
|
||||
public int count;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (!origin) return;
|
||||
origin.SetActive(false);
|
||||
|
||||
var parent = origin.transform.parent;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var go = Instantiate(origin, parent, false);
|
||||
go.name = string.Format("{0} {1}", origin.name, i + 1);
|
||||
go.hideFlags = HideFlags.DontSave;
|
||||
go.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Samples~/Demo/Scripts/CopyItemOnStart.cs.meta
Normal file
11
Samples~/Demo/Scripts/CopyItemOnStart.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01a6a172129d6453eb661239d2b1e850
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
82
Samples~/Demo/Scripts/UIElementDragger.cs
Normal file
82
Samples~/Demo/Scripts/UIElementDragger.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class UIElementDragger : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
public enum Target
|
||||
{
|
||||
Self,
|
||||
Parent,
|
||||
Custom,
|
||||
}
|
||||
|
||||
private RectTransform rectTransform;
|
||||
private Canvas canvas;
|
||||
public Target m_Target;
|
||||
public Transform m_CustomTarget;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
canvas = GetComponentInParent<Canvas>();
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
var delta = (Vector3)GetLocalDelta(eventData.delta);
|
||||
|
||||
switch (m_Target)
|
||||
{
|
||||
case Target.Self:
|
||||
rectTransform.localPosition += delta;
|
||||
break;
|
||||
case Target.Parent:
|
||||
rectTransform.parent.localPosition += delta;
|
||||
break;
|
||||
case Target.Custom:
|
||||
rectTransform.localPosition += delta;
|
||||
if (m_CustomTarget)
|
||||
{
|
||||
m_CustomTarget.localPosition += delta;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
}
|
||||
|
||||
private Vector2 GetLocalDelta(Vector2 evDelta)
|
||||
{
|
||||
switch (canvas.renderMode)
|
||||
{
|
||||
case RenderMode.ScreenSpaceOverlay:
|
||||
{
|
||||
var zero = transform.InverseTransformPoint(Vector2.zero);
|
||||
var delta = transform.InverseTransformPoint(evDelta);
|
||||
return delta - zero;
|
||||
}
|
||||
case RenderMode.ScreenSpaceCamera:
|
||||
{
|
||||
Vector2 zero, delta;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Vector2.zero, canvas.worldCamera, out zero);
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, evDelta, canvas.worldCamera, out delta);
|
||||
return delta - zero;
|
||||
}
|
||||
case RenderMode.WorldSpace:
|
||||
{
|
||||
Vector3 zero, delta;
|
||||
RectTransformUtility.ScreenPointToWorldPointInRectangle(rectTransform, Vector2.zero, canvas.worldCamera, out zero);
|
||||
RectTransformUtility.ScreenPointToWorldPointInRectangle(rectTransform, evDelta, canvas.worldCamera, out delta);
|
||||
return delta - zero;
|
||||
}
|
||||
default:
|
||||
throw new System.NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Samples~/Demo/Scripts/UIElementDragger.cs.meta
Normal file
11
Samples~/Demo/Scripts/UIElementDragger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1979128e1e7d427cb18fde94c6ff4b5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
167
Samples~/Demo/Scripts/UIParticle_Demo.cs
Normal file
167
Samples~/Demo/Scripts/UIParticle_Demo.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIExtensions.Demo
|
||||
{
|
||||
public class UIParticle_Demo : MonoBehaviour
|
||||
{
|
||||
public Canvas root;
|
||||
|
||||
private int _width;
|
||||
private int _height;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_width = Screen.width;
|
||||
_height = Screen.height;
|
||||
}
|
||||
|
||||
public void ResizeScreen()
|
||||
{
|
||||
switch (Application.platform)
|
||||
{
|
||||
case RuntimePlatform.OSXPlayer:
|
||||
case RuntimePlatform.WindowsPlayer:
|
||||
case RuntimePlatform.LinuxPlayer:
|
||||
if (Screen.width == _width && Screen.height == _height)
|
||||
Screen.SetResolution(_height, _width, Screen.fullScreen);
|
||||
else if (Screen.width == _height && Screen.height == _width)
|
||||
Screen.SetResolution(Mathf.Min(_width, _height), Mathf.Min(_width, _height), Screen.fullScreen);
|
||||
else
|
||||
Screen.SetResolution(_width, _height, Screen.fullScreen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void FullScreen()
|
||||
{
|
||||
Screen.fullScreen = !Screen.fullScreen;
|
||||
}
|
||||
|
||||
public void EnableAnimations(bool enabled)
|
||||
{
|
||||
foreach (var animator in FindObjectsOfType<Animator>())
|
||||
{
|
||||
animator.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
public void UIParticle_MeshSharing(bool enabled)
|
||||
{
|
||||
foreach (var uip in root.GetComponentsInChildren<UIParticle>(true))
|
||||
{
|
||||
uip.meshSharing = enabled ? UIParticle.MeshSharing.Auto : UIParticle.MeshSharing.None;
|
||||
}
|
||||
}
|
||||
|
||||
public void UIParticle_RandomGroup(bool enabled)
|
||||
{
|
||||
foreach (var uip in root.GetComponentsInChildren<UIParticle>(true))
|
||||
{
|
||||
uip.groupMaxId = enabled ? 4 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void UIParticle_Scale(float scale)
|
||||
{
|
||||
foreach (var uip in FindObjectsOfType<UIParticle>())
|
||||
{
|
||||
uip.scale = scale;
|
||||
}
|
||||
}
|
||||
|
||||
public void ParticleSystem_WorldSpaseSimulation(bool enabled)
|
||||
{
|
||||
foreach (var ps in FindObjectsOfType<ParticleSystem>())
|
||||
{
|
||||
var main = ps.main;
|
||||
main.simulationSpace = enabled ? ParticleSystemSimulationSpace.World : ParticleSystemSimulationSpace.Local;
|
||||
}
|
||||
}
|
||||
|
||||
public void ParticleSystem_WorldSpaseSimulation(ParticleSystem particleSystem)
|
||||
{
|
||||
foreach (var ps in particleSystem.GetComponentsInChildren<ParticleSystem>())
|
||||
{
|
||||
var main = ps.main;
|
||||
main.simulationSpace = ParticleSystemSimulationSpace.World;
|
||||
ps.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void ParticleSystem_LocalSpaseSimulation(ParticleSystem particleSystem)
|
||||
{
|
||||
foreach (var ps in particleSystem.GetComponentsInChildren<ParticleSystem>())
|
||||
{
|
||||
var main = ps.main;
|
||||
main.simulationSpace = ParticleSystemSimulationSpace.Local;
|
||||
ps.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void ParticleSystem_Emit(ParticleSystem particleSystem)
|
||||
{
|
||||
particleSystem.Emit(5);
|
||||
}
|
||||
|
||||
public void ParticleSystem_SetScale(float scale)
|
||||
{
|
||||
foreach (var ps in FindObjectsOfType<ParticleSystem>())
|
||||
{
|
||||
ps.transform.localScale = new Vector3(scale, scale, scale);
|
||||
}
|
||||
}
|
||||
|
||||
public void UIParticleAttractor_Linear(UIParticleAttractor attractor)
|
||||
{
|
||||
attractor.movement = UIParticleAttractor.Movement.Linear;
|
||||
}
|
||||
|
||||
public void UIParticleAttractor_Smooth(UIParticleAttractor attractor)
|
||||
{
|
||||
attractor.movement = UIParticleAttractor.Movement.Smooth;
|
||||
}
|
||||
|
||||
public void UIParticleAttractor_Sphere(UIParticleAttractor attractor)
|
||||
{
|
||||
attractor.movement = UIParticleAttractor.Movement.Sphere;
|
||||
}
|
||||
|
||||
int score = 0;
|
||||
public void UIParticleAttractor_OnAttract(Text scoreText)
|
||||
{
|
||||
score++;
|
||||
scoreText.text = score.ToString();
|
||||
scoreText.GetComponent<Animator>().Play(0);
|
||||
}
|
||||
|
||||
public void Canvas_WorldSpace(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
var canvas = FindObjectOfType<Canvas>();
|
||||
canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
||||
canvas.renderMode = RenderMode.WorldSpace;
|
||||
canvas.transform.rotation = Quaternion.Euler(new Vector3(0, 10, 0));
|
||||
}
|
||||
}
|
||||
|
||||
public void Canvas_CameraSpace(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
var canvas = FindObjectOfType<Canvas>();
|
||||
canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
||||
}
|
||||
}
|
||||
|
||||
public void Canvas_Overlay(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
var canvas = FindObjectOfType<Canvas>();
|
||||
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Samples~/Demo/Scripts/UIParticle_Demo.cs.meta
Normal file
11
Samples~/Demo/Scripts/UIParticle_Demo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eba3b7ce20b7f470a891c84def6be7e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions.Demo
|
||||
{
|
||||
public class UIParticle_Demo_UIParticleController : MonoBehaviour
|
||||
{
|
||||
public Transform root;
|
||||
|
||||
public void UIParticle_MeshSharing(bool enabled)
|
||||
{
|
||||
foreach (var uip in root.GetComponentsInChildren<UIParticle>(true))
|
||||
{
|
||||
uip.meshSharing = enabled ? UIParticle.MeshSharing.Auto : UIParticle.MeshSharing.None;
|
||||
}
|
||||
}
|
||||
|
||||
public void UIParticle_RandomGroup(bool enabled)
|
||||
{
|
||||
foreach (var uip in root.GetComponentsInChildren<UIParticle>(true))
|
||||
{
|
||||
uip.groupMaxId = enabled ? 4 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void UIParticle_Scale(float scale)
|
||||
{
|
||||
foreach (var uip in root.GetComponentsInChildren<UIParticle>(true))
|
||||
{
|
||||
uip.scale = scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3256d3a1b8cfa4982941c7e7eb17947d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user