|
|
|
|
//////////////////////////////////////////////
|
|
|
|
|
/// 2DxFX - 2D SPRITE FX - by VETASOFT 2018 //
|
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
[ExecuteInEditMode]
|
|
|
|
|
[AddComponentMenu("2DxFX/Advanced Lightning/LightningBolt")]
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class _2dxFX_AL_LightningBolt : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[HideInInspector] public Material ForceMaterial;
|
|
|
|
|
// Advanced Lightning
|
|
|
|
|
[HideInInspector] public bool ActiveChange = true;
|
|
|
|
|
[HideInInspector] public bool AddShadow = true;
|
|
|
|
|
[HideInInspector] public bool ReceivedShadow = false;
|
|
|
|
|
[HideInInspector] public int BlendMode = 0;
|
|
|
|
|
|
|
|
|
|
private string shader = "2DxFX/AL/LightningBolt";
|
|
|
|
|
[HideInInspector] [Range(0, 1)] public float _Alpha = 1f;
|
|
|
|
|
|
|
|
|
|
[HideInInspector] public Texture2D __MainTex2;
|
|
|
|
|
[HideInInspector] [Range(16, 256)] public float _Value1 = 64;
|
|
|
|
|
[HideInInspector] [Range(0, 2)] public float _Value2 = 1;
|
|
|
|
|
[HideInInspector] [Range(0, 1)] public float _Value3 = 1;
|
|
|
|
|
[HideInInspector] public float _Value4;
|
|
|
|
|
|
|
|
|
|
[HideInInspector] public bool _AutoScrollX;
|
|
|
|
|
[HideInInspector] [Range(0, 10)] public float _AutoScrollSpeedX;
|
|
|
|
|
[HideInInspector] public bool _AutoScrollY;
|
|
|
|
|
[HideInInspector] [Range(0, 10)] public float _AutoScrollSpeedY;
|
|
|
|
|
[HideInInspector] private float _AutoScrollCountX;
|
|
|
|
|
[HideInInspector] private float _AutoScrollCountY;
|
|
|
|
|
|
|
|
|
|
[HideInInspector] public int ShaderChange = 0;
|
|
|
|
|
Material tempMaterial;
|
|
|
|
|
Material defaultMaterial;
|
|
|
|
|
Image CanvasImage;
|
|
|
|
|
SpriteRenderer CanvasSpriteRenderer;[HideInInspector] public bool ActiveUpdate = true;
|
|
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
if (this.gameObject.GetComponent<Image>() != null) CanvasImage = this.gameObject.GetComponent<Image>();
|
|
|
|
|
if (this.gameObject.GetComponent<SpriteRenderer>() != null) CanvasSpriteRenderer = this.gameObject.GetComponent<SpriteRenderer>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
__MainTex2 = Resources.Load("_2dxFX_LightningTXT") as Texture2D;
|
|
|
|
|
ShaderChange = 0;
|
|
|
|
|
if (CanvasSpriteRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetTexture("_MainTex2", __MainTex2);
|
|
|
|
|
}
|
|
|
|
|
else if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasImage.material.SetTexture("_MainTex2", __MainTex2);
|
|
|
|
|
}
|
|
|
|
|
XUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CallUpdate()
|
|
|
|
|
{
|
|
|
|
|
XUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
if (ActiveUpdate) XUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XUpdate()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (CanvasImage == null)
|
|
|
|
|
{
|
|
|
|
|
if (this.gameObject.GetComponent<Image>() != null) CanvasImage = this.gameObject.GetComponent<Image>();
|
|
|
|
|
}
|
|
|
|
|
if (CanvasSpriteRenderer == null)
|
|
|
|
|
{
|
|
|
|
|
if (this.gameObject.GetComponent<SpriteRenderer>() != null) CanvasSpriteRenderer = this.gameObject.GetComponent<SpriteRenderer>();
|
|
|
|
|
}
|
|
|
|
|
if ((ShaderChange == 0) && (ForceMaterial != null))
|
|
|
|
|
{
|
|
|
|
|
ShaderChange = 1;
|
|
|
|
|
if (tempMaterial != null) DestroyImmediate(tempMaterial);
|
|
|
|
|
if (CanvasSpriteRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial = ForceMaterial;
|
|
|
|
|
}
|
|
|
|
|
else if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasImage.material = ForceMaterial;
|
|
|
|
|
}
|
|
|
|
|
ForceMaterial.hideFlags = HideFlags.None;
|
|
|
|
|
ForceMaterial.shader = Shader.Find(shader);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if ((ForceMaterial == null) && (ShaderChange == 1))
|
|
|
|
|
{
|
|
|
|
|
if (tempMaterial != null) DestroyImmediate(tempMaterial);
|
|
|
|
|
tempMaterial = new Material(Shader.Find(shader));
|
|
|
|
|
tempMaterial.hideFlags = HideFlags.None;
|
|
|
|
|
if (CanvasSpriteRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial = tempMaterial;
|
|
|
|
|
}
|
|
|
|
|
else if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasImage.material = tempMaterial;
|
|
|
|
|
}
|
|
|
|
|
ShaderChange = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
string dfname = "";
|
|
|
|
|
if (CanvasSpriteRenderer != null) dfname = CanvasSpriteRenderer.sharedMaterial.shader.name;
|
|
|
|
|
if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
Image img = CanvasImage;
|
|
|
|
|
if (img.material == null) dfname = "Sprites/Default";
|
|
|
|
|
}
|
|
|
|
|
if (dfname == "Sprites/Default")
|
|
|
|
|
{
|
|
|
|
|
ForceMaterial.shader = Shader.Find(shader);
|
|
|
|
|
ForceMaterial.hideFlags = HideFlags.None;
|
|
|
|
|
if (CanvasSpriteRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial = ForceMaterial;
|
|
|
|
|
}
|
|
|
|
|
else if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
Image img = CanvasImage;
|
|
|
|
|
if (img.material == null)
|
|
|
|
|
{
|
|
|
|
|
CanvasImage.material = ForceMaterial;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
__MainTex2 = Resources.Load("_2dxFX_LightningTXT") as Texture2D;
|
|
|
|
|
if (CanvasSpriteRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetTexture("_MainTex2", __MainTex2);
|
|
|
|
|
}
|
|
|
|
|
else if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
Image img = CanvasImage;
|
|
|
|
|
if (img.material == null)
|
|
|
|
|
{
|
|
|
|
|
CanvasImage.material.SetTexture("_MainTex2", __MainTex2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
if (ActiveChange)
|
|
|
|
|
{
|
|
|
|
|
if (CanvasSpriteRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetFloat("_Alpha", 1 - _Alpha);
|
|
|
|
|
if (_2DxFX.ActiveShadow && AddShadow)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
|
|
|
|
|
if (ReceivedShadow)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.receiveShadows = true;
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.renderQueue = 2450;
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_Z", 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.receiveShadows = false;
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.renderQueue = 3000;
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_Z", 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
|
|
|
|
|
CanvasSpriteRenderer.receiveShadows = false;
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.renderQueue = 3000;
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_Z", 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BlendMode == 0) // LetterEntered
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_BlendOp", (int)UnityEngine.Rendering.BlendOp.Add);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
|
|
|
|
}
|
|
|
|
|
if (BlendMode == 1) // Additive
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_BlendOp", (int)UnityEngine.Rendering.BlendOp.Add);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
|
|
|
|
}
|
|
|
|
|
if (BlendMode == 2) // Darken
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_BlendOp", (int)UnityEngine.Rendering.BlendOp.ReverseSubtract);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.DstColor);
|
|
|
|
|
}
|
|
|
|
|
if (BlendMode == 3) // Lighten
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_BlendOp", (int)UnityEngine.Rendering.BlendOp.Max);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
|
|
|
|
}
|
|
|
|
|
if (BlendMode == 4) // Linear Burn
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_BlendOp", (int)UnityEngine.Rendering.BlendOp.ReverseSubtract);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
|
|
|
|
}
|
|
|
|
|
if (BlendMode == 5) // Linear Dodge
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_BlendOp", (int)UnityEngine.Rendering.BlendOp.Max);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
|
|
|
|
}
|
|
|
|
|
if (BlendMode == 6) // Multiply
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_BlendOp", (int)UnityEngine.Rendering.BlendOp.Add);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.DstColor);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
|
|
|
|
}
|
|
|
|
|
if (BlendMode == 7) // Soft Aditive
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_BlendOp", (int)UnityEngine.Rendering.BlendOp.Add);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusDstColor);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
|
|
|
|
}
|
|
|
|
|
if (BlendMode == 8) // 2x Multiplicative
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_BlendOp", (int)UnityEngine.Rendering.BlendOp.ReverseSubtract);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.DstAlpha);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.DstColor);
|
|
|
|
|
}
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetFloat("_Value1", _Value1);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetFloat("_Value2", _Value2);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetFloat("_Value3", _Value3);
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetFloat("_Value4", _Value4);
|
|
|
|
|
}
|
|
|
|
|
else if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasImage.material.SetFloat("_Alpha", 1 - _Alpha);
|
|
|
|
|
CanvasImage.material.SetFloat("_Value1", _Value1);
|
|
|
|
|
CanvasImage.material.SetFloat("_Value2", _Value2);
|
|
|
|
|
CanvasImage.material.SetFloat("_Value3", _Value3);
|
|
|
|
|
CanvasImage.material.SetFloat("_Value4", _Value4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if ((Application.isPlaying == false) && (Application.isEditor == true))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (tempMaterial != null) DestroyImmediate(tempMaterial);
|
|
|
|
|
|
|
|
|
|
if (gameObject.activeSelf && defaultMaterial != null)
|
|
|
|
|
{
|
|
|
|
|
if (CanvasSpriteRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial = defaultMaterial;
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.hideFlags = HideFlags.None;
|
|
|
|
|
}
|
|
|
|
|
else if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasImage.material = defaultMaterial;
|
|
|
|
|
CanvasImage.material.hideFlags = HideFlags.None;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void OnDisable()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (gameObject.activeSelf && defaultMaterial != null)
|
|
|
|
|
{
|
|
|
|
|
if (CanvasSpriteRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial = defaultMaterial;
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.hideFlags = HideFlags.None;
|
|
|
|
|
}
|
|
|
|
|
else if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasImage.material = defaultMaterial;
|
|
|
|
|
CanvasImage.material.hideFlags = HideFlags.None;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (defaultMaterial == null)
|
|
|
|
|
{
|
|
|
|
|
defaultMaterial = new Material(Shader.Find("Sprites/Default"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (ForceMaterial == null)
|
|
|
|
|
{
|
|
|
|
|
ActiveChange = true;
|
|
|
|
|
tempMaterial = new Material(Shader.Find(shader));
|
|
|
|
|
tempMaterial.hideFlags = HideFlags.None;
|
|
|
|
|
if (CanvasSpriteRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial = tempMaterial;
|
|
|
|
|
}
|
|
|
|
|
else if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasImage.material = tempMaterial;
|
|
|
|
|
}
|
|
|
|
|
__MainTex2 = Resources.Load("_2dxFX_LightningTXT") as Texture2D;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ForceMaterial.shader = Shader.Find(shader);
|
|
|
|
|
ForceMaterial.hideFlags = HideFlags.None;
|
|
|
|
|
if (CanvasSpriteRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial = ForceMaterial;
|
|
|
|
|
}
|
|
|
|
|
else if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasImage.material = ForceMaterial;
|
|
|
|
|
}
|
|
|
|
|
__MainTex2 = Resources.Load("_2dxFX_LightningTXT") as Texture2D;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (__MainTex2)
|
|
|
|
|
{
|
|
|
|
|
__MainTex2.wrapMode = TextureWrapMode.Repeat;
|
|
|
|
|
if (CanvasSpriteRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasSpriteRenderer.sharedMaterial.SetTexture("_MainTex2", __MainTex2);
|
|
|
|
|
}
|
|
|
|
|
else if (CanvasImage != null)
|
|
|
|
|
{
|
|
|
|
|
CanvasImage.material.SetTexture("_MainTex2", __MainTex2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
[CustomEditor(typeof(_2dxFX_AL_LightningBolt)), CanEditMultipleObjects]
|
|
|
|
|
public class _2dxFX_AL_LightningBolt_Editor : Editor
|
|
|
|
|
{
|
|
|
|
|
private SerializedObject m_object;
|
|
|
|
|
|
|
|
|
|
public void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
m_object = new SerializedObject(targets);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnInspectorGUI()
|
|
|
|
|
{
|
|
|
|
|
m_object.Update();
|
|
|
|
|
DrawDefaultInspector();
|
|
|
|
|
|
|
|
|
|
_2dxFX_AL_LightningBolt _2dxScript = (_2dxFX_AL_LightningBolt)target;
|
|
|
|
|
|
|
|
|
|
Texture2D icon = Resources.Load("2dxfxinspector-al") as Texture2D;
|
|
|
|
|
if (icon)
|
|
|
|
|
{
|
|
|
|
|
Rect r;
|
|
|
|
|
float ih = icon.height;
|
|
|
|
|
float iw = icon.width;
|
|
|
|
|
float result = ih / iw;
|
|
|
|
|
float w = Screen.width;
|
|
|
|
|
result = result * w;
|
|
|
|
|
r = GUILayoutUtility.GetRect(ih, result);
|
|
|
|
|
EditorGUI.DrawTextureTransparent(r, icon);
|
|
|
|
|
}
|
|
|
|
|
EditorGUILayout.LabelField("Advanced Lightning may work on mobile high-end devices and may be slower than the Standard 2DxFX effects due to is lightning system. Use it only if you need it.", EditorStyles.helpBox);
|
|
|
|
|
EditorGUILayout.PropertyField(m_object.FindProperty("AddShadow"), new GUIContent("Add Shadow", "Use a unique material, reduce drastically the use of draw call"));
|
|
|
|
|
if (_2dxScript.AddShadow)
|
|
|
|
|
{
|
|
|
|
|
EditorGUILayout.PropertyField(m_object.FindProperty("ReceivedShadow"), new GUIContent("Received Shadow : No Transparency and Use Z Buffering instead of Sprite Order Layers", "Received Shadow, No Transparency and Use Z Buffering instead of Sprite Order Layers"));
|
|
|
|
|
if (_2dxScript.ReceivedShadow)
|
|
|
|
|
{
|
|
|
|
|
EditorGUILayout.LabelField("Note 1: Blend Fusion work but without transparency\n", EditorStyles.helpBox);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mode Blend
|
|
|
|
|
string BlendMethode = "LetterEntered";
|
|
|
|
|
|
|
|
|
|
if (_2dxScript.BlendMode == 0) BlendMethode = "LetterEntered";
|
|
|
|
|
if (_2dxScript.BlendMode == 1) BlendMethode = "Additive";
|
|
|
|
|
if (_2dxScript.BlendMode == 2) BlendMethode = "Darken";
|
|
|
|
|
if (_2dxScript.BlendMode == 3) BlendMethode = "Lighten";
|
|
|
|
|
if (_2dxScript.BlendMode == 4) BlendMethode = "Linear Burn";
|
|
|
|
|
if (_2dxScript.BlendMode == 5) BlendMethode = "Linear Dodge";
|
|
|
|
|
if (_2dxScript.BlendMode == 6) BlendMethode = "Multiply";
|
|
|
|
|
if (_2dxScript.BlendMode == 7) BlendMethode = "Soft Aditive";
|
|
|
|
|
if (_2dxScript.BlendMode == 8) BlendMethode = "2x Multiplicative";
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.PropertyField(m_object.FindProperty("ActiveUpdate"), new GUIContent("Active Update", "Active Update, for animation / Animator only")); EditorGUILayout.PropertyField(m_object.FindProperty("ForceMaterial"), new GUIContent("Shared Material", "Use a unique material, reduce drastically the use of draw call"));
|
|
|
|
|
|
|
|
|
|
if (_2dxScript.ForceMaterial == null)
|
|
|
|
|
{
|
|
|
|
|
_2dxScript.ActiveChange = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (GUILayout.Button("Remove Shared Material"))
|
|
|
|
|
{
|
|
|
|
|
_2dxScript.ForceMaterial = null;
|
|
|
|
|
_2dxScript.ShaderChange = 1;
|
|
|
|
|
_2dxScript.ActiveChange = true;
|
|
|
|
|
_2dxScript.CallUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.PropertyField(m_object.FindProperty("ActiveChange"), new GUIContent("Change Material Property", "Change The Material Property"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_2dxScript.ActiveChange)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.BeginVertical("Box");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Texture2D icone = Resources.Load("2dxfx-icon-time") as Texture2D;
|
|
|
|
|
EditorGUILayout.PropertyField(m_object.FindProperty("_Value1"), new GUIContent("Lightning Bolt Speed", icone, "Change the fire speed"));
|
|
|
|
|
|
|
|
|
|
icone = Resources.Load("2dxfx-icon-brightness") as Texture2D;
|
|
|
|
|
EditorGUILayout.PropertyField(m_object.FindProperty("_Value2"), new GUIContent("Lightning Bolt Intensity", icone, "Change the fire light intensity"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.BeginVertical("Box");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
icone = Resources.Load("2dxfx-icon-fade") as Texture2D;
|
|
|
|
|
EditorGUILayout.PropertyField(m_object.FindProperty("_Alpha"), new GUIContent("Fading", icone, "Fade from nothing to showing"));
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.EndVertical();
|
|
|
|
|
EditorGUILayout.EndVertical();
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.BeginVertical("Box");
|
|
|
|
|
EditorGUILayout.LabelField("Change Blend Fusion = " + BlendMethode, EditorStyles.whiteLargeLabel);
|
|
|
|
|
if (_2dxScript.ReceivedShadow)
|
|
|
|
|
{
|
|
|
|
|
EditorGUILayout.LabelField("Note: Blend Fusion is not working correctly with Received Shadow", EditorStyles.helpBox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.BeginHorizontal("Box");
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("LetterEntered", EditorStyles.toolbarButton))
|
|
|
|
|
{
|
|
|
|
|
_2dxScript.BlendMode = 0;
|
|
|
|
|
_2dxScript.CallUpdate();
|
|
|
|
|
}
|
|
|
|
|
if (GUILayout.Button("Additive", EditorStyles.toolbarButton))
|
|
|
|
|
{
|
|
|
|
|
_2dxScript.BlendMode = 1;
|
|
|
|
|
_2dxScript.CallUpdate();
|
|
|
|
|
}
|
|
|
|
|
if (GUILayout.Button("Darken", EditorStyles.toolbarButton))
|
|
|
|
|
{
|
|
|
|
|
_2dxScript.BlendMode = 2;
|
|
|
|
|
_2dxScript.CallUpdate();
|
|
|
|
|
}
|
|
|
|
|
if (GUILayout.Button("Lighten", EditorStyles.toolbarButton))
|
|
|
|
|
{
|
|
|
|
|
_2dxScript.BlendMode = 3;
|
|
|
|
|
_2dxScript.CallUpdate();
|
|
|
|
|
}
|
|
|
|
|
if (GUILayout.Button("Linear Burn", EditorStyles.toolbarButton))
|
|
|
|
|
{
|
|
|
|
|
_2dxScript.BlendMode = 4;
|
|
|
|
|
_2dxScript.CallUpdate();
|
|
|
|
|
}
|
|
|
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
|
EditorGUILayout.BeginHorizontal("Box");
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("Linear Dodge", EditorStyles.toolbarButton))
|
|
|
|
|
{
|
|
|
|
|
_2dxScript.BlendMode = 5;
|
|
|
|
|
_2dxScript.CallUpdate();
|
|
|
|
|
}
|
|
|
|
|
if (GUILayout.Button("Multiply", EditorStyles.toolbarButton))
|
|
|
|
|
{
|
|
|
|
|
_2dxScript.BlendMode = 6;
|
|
|
|
|
_2dxScript.CallUpdate();
|
|
|
|
|
}
|
|
|
|
|
if (GUILayout.Button("Soft Aditive", EditorStyles.toolbarButton))
|
|
|
|
|
{
|
|
|
|
|
_2dxScript.BlendMode = 7;
|
|
|
|
|
_2dxScript.CallUpdate();
|
|
|
|
|
}
|
|
|
|
|
if (GUILayout.Button("2x Multiplicative", EditorStyles.toolbarButton))
|
|
|
|
|
{
|
|
|
|
|
_2dxScript.BlendMode = 8;
|
|
|
|
|
_2dxScript.CallUpdate();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
|
EditorGUILayout.EndVertical();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_object.ApplyModifiedProperties();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|