작업 조건 분석 기능 개발
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// manages all the chart effect for a chart item. This includes scale translation and rotation effects
|
||||
/// </summary>
|
||||
public class CharItemEffectController : MonoBehaviour
|
||||
{
|
||||
List<ChartItemEffect> mEffects = new List<ChartItemEffect>();
|
||||
Transform mParent;
|
||||
internal bool WorkOnParent { get; set; }
|
||||
internal bool InitialScale { get; set; }
|
||||
Vector3 mInitialScale;
|
||||
protected Transform Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mParent == null)
|
||||
mParent = transform.parent;
|
||||
return mParent;
|
||||
}
|
||||
}
|
||||
public CharItemEffectController()
|
||||
{
|
||||
InitialScale = true;
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
mInitialScale = transform.localScale;
|
||||
}
|
||||
void OnTransformParentChanged()
|
||||
{
|
||||
mInitialScale = transform.localScale;
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
Transform trans = transform;
|
||||
if (WorkOnParent)
|
||||
{
|
||||
trans = Parent;
|
||||
if (trans == null)
|
||||
return;
|
||||
}
|
||||
Vector3 scale = new Vector3(1f,1f,1f);
|
||||
if (InitialScale)
|
||||
scale = mInitialScale;
|
||||
Vector3 translation = Vector3.zero;
|
||||
Quaternion rotation = Quaternion.identity;
|
||||
|
||||
for (int i=0; i<mEffects.Count; i++)
|
||||
{
|
||||
ChartItemEffect effect = mEffects[i];
|
||||
if (effect == null || effect.gameObject == null)
|
||||
{
|
||||
mEffects.RemoveAt(i);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
scale.x *= effect.ScaleMultiplier.x;
|
||||
scale.y *= effect.ScaleMultiplier.y;
|
||||
scale.z *= effect.ScaleMultiplier.z;
|
||||
|
||||
translation += effect.Translation;
|
||||
rotation *= effect.Rotation;
|
||||
}
|
||||
trans.localScale = scale;
|
||||
}
|
||||
|
||||
public void Unregister(ChartItemEffect effect)
|
||||
{
|
||||
mEffects.Remove(effect);
|
||||
if(mEffects.Count == 0)
|
||||
enabled = false;
|
||||
}
|
||||
public void Register(ChartItemEffect effect)
|
||||
{
|
||||
if (mEffects.Contains(effect))
|
||||
return;
|
||||
if (enabled == false)
|
||||
enabled = true;
|
||||
mEffects.Add(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d991d151f2c9184aa1f2b9cc6106d32
|
||||
timeCreated: 1478280231
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
90
Assets/Chart And Graph/Script/ChartItem/ChartItemEffect.cs
Normal file
90
Assets/Chart And Graph/Script/ChartItem/ChartItemEffect.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// base class for all chart item effects
|
||||
/// </summary>
|
||||
public abstract class ChartItemEffect : MonoBehaviour
|
||||
{
|
||||
internal int ItemIndex { get; set; }
|
||||
internal int ItemType { get; set; }
|
||||
internal object ItemData { get; set; }
|
||||
CharItemEffectController mController;
|
||||
protected CharItemEffectController Controller
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mController == null)
|
||||
{
|
||||
mController = GetComponent<CharItemEffectController>();
|
||||
if (mController == null)
|
||||
mController = gameObject.AddComponent<CharItemEffectController>();
|
||||
}
|
||||
return mController;
|
||||
}
|
||||
}
|
||||
public event Action<ChartItemEffect> Deactivate;
|
||||
|
||||
protected void RaiseDeactivated()
|
||||
{
|
||||
if (Deactivate != null)
|
||||
Deactivate(this);
|
||||
}
|
||||
|
||||
private void Register()
|
||||
{
|
||||
CharItemEffectController control = Controller;
|
||||
if (control != null)
|
||||
control.Register(this);
|
||||
}
|
||||
private void Unregister()
|
||||
{
|
||||
CharItemEffectController control = Controller;
|
||||
if (control != null)
|
||||
control.Unregister(this);
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
Unregister();
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
Register();
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
Register();
|
||||
}
|
||||
|
||||
protected virtual void Destroy()
|
||||
{
|
||||
Unregister();
|
||||
}
|
||||
|
||||
public abstract void TriggerIn(bool deactivateOnEnd);
|
||||
|
||||
public abstract void TriggerOut(bool deactivateOnEnd);
|
||||
|
||||
/// <summary>
|
||||
/// applies a scaling to the object
|
||||
/// </summary>
|
||||
internal abstract Vector3 ScaleMultiplier {get;}
|
||||
/// <summary>
|
||||
/// applies rotation to the object
|
||||
/// </summary>
|
||||
internal abstract Quaternion Rotation { get; }
|
||||
/// <summary>
|
||||
/// applies translation to the object
|
||||
/// </summary>
|
||||
internal abstract Vector3 Translation { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6043c38a5ccc54f43aac9950abeb22c3
|
||||
timeCreated: 1478283683
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
135
Assets/Chart And Graph/Script/ChartItem/ChartItemEvents.cs
Normal file
135
Assets/Chart And Graph/Script/ChartItem/ChartItemEvents.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// provides functionallity for recieving events for chart items (such as bars and pie slices)
|
||||
/// </summary>
|
||||
public class ChartItemEvents : MonoBehaviour , IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler,IPointerUpHandler, InternalItemEvents
|
||||
{
|
||||
[Serializable]
|
||||
public class Event : UnityEvent<GameObject>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// occures when the mouse is over the item
|
||||
/// </summary>
|
||||
[Tooltip("Occures when the mouse is over the item")]
|
||||
public Event OnMouseHover = new Event();
|
||||
/// <summary>
|
||||
/// occurs when the mouse is no longer over the item
|
||||
/// </summary>
|
||||
[Tooltip("Occurs when the mouse is no longer over the item")]
|
||||
public Event OnMouseLeave = new Event();
|
||||
/// <summary>
|
||||
/// occurs when the user clicks the chart item
|
||||
/// </summary>
|
||||
[Tooltip("Occurs when the user clicks the chart item")]
|
||||
public Event OnSelected = new Event();
|
||||
|
||||
private bool mMouseOver = false;
|
||||
private bool mMouseDown = false;
|
||||
|
||||
private IInternalUse mParent;
|
||||
private object mUserData;
|
||||
|
||||
IInternalUse InternalItemEvents.Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
return mParent;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
mParent = value;
|
||||
}
|
||||
}
|
||||
|
||||
object InternalItemEvents.UserData
|
||||
{
|
||||
get
|
||||
{
|
||||
return mUserData;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
mUserData = value;
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnMouseEnter()
|
||||
{
|
||||
if (mMouseOver == false)
|
||||
OnMouseHover.Invoke(gameObject);
|
||||
if (mParent != null)
|
||||
mParent.InternalItemHovered(mUserData);
|
||||
mMouseOver = true;
|
||||
}
|
||||
|
||||
void OnMouseExit()
|
||||
{
|
||||
if(mMouseOver == true)
|
||||
OnMouseLeave.Invoke(gameObject);
|
||||
if (mParent != null)
|
||||
mParent.InternalItemLeave(mUserData);
|
||||
mMouseOver = false;
|
||||
|
||||
}
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
if (mMouseDown == false)
|
||||
OnSelected.Invoke(gameObject);
|
||||
if (mParent != null)
|
||||
mParent.InternalItemSelected(mUserData);
|
||||
mMouseDown = true;
|
||||
}
|
||||
|
||||
void OnMouseUp()
|
||||
{
|
||||
mMouseDown = false;
|
||||
}
|
||||
public void Select(bool selected)
|
||||
{
|
||||
if (selected)
|
||||
OnMouseEnter();
|
||||
else
|
||||
OnMouseExit();
|
||||
}
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
OnMouseEnter();
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
OnMouseExit();
|
||||
}
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
OnMouseDown();
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
OnMouseUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec91821f11c13dc4399cd444b0f3360a
|
||||
timeCreated: 1478284152
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
179
Assets/Chart And Graph/Script/ChartItem/ChartItemGrowEffect.cs
Normal file
179
Assets/Chart And Graph/Script/ChartItem/ChartItemGrowEffect.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// makes the chart item grow and shrink with easing. this can be connected to hover events for example
|
||||
/// </summary>
|
||||
class ChartItemGrowEffect : ChartItemEffect
|
||||
{
|
||||
const int NoOp = 0;
|
||||
const int GrowOp = 1;
|
||||
const int ShrinkOp = 2;
|
||||
const int GrowShrinkOp = 3;
|
||||
public float GrowMultiplier = 1.2f;
|
||||
|
||||
public bool VerticalOnly = false;
|
||||
public bool HorizontalOnly = false;
|
||||
/// <summary>
|
||||
/// scales the time used in the easing curves
|
||||
/// </summary>
|
||||
public float TimeScale = 1f;
|
||||
/// <summary>
|
||||
/// easing function for the grow effect. when the curve is at 0 there will be no change , when the curve is at 1 the change will be equal to the GrowMultiplier property
|
||||
/// </summary>
|
||||
public AnimationCurve GrowEaseFunction = AnimationCurve.EaseInOut(0f,0f,1f,1f);
|
||||
/// <summary>
|
||||
/// easing function for the shrink effect. when the curve is at 0 there will be no change , when the curve is at 1 the change will be equal to the GrowMultiplier property
|
||||
/// </summary>
|
||||
public AnimationCurve ShrinkEaseFunction = AnimationCurve.EaseInOut(1f, 1f, 0f, 0f);
|
||||
|
||||
float mScaleMultiplier = 1f;
|
||||
float mStartTime = 0f;
|
||||
float mStartValue = 0f;
|
||||
int Operation = NoOp;
|
||||
bool mDeactivateOnEnd = false;
|
||||
internal override Vector3 ScaleMultiplier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (VerticalOnly && !HorizontalOnly)
|
||||
return new Vector3(1f, mScaleMultiplier, 1f);
|
||||
if(HorizontalOnly && !VerticalOnly)
|
||||
return new Vector3(mScaleMultiplier, 1f, 1f);
|
||||
return new Vector3(mScaleMultiplier, mScaleMultiplier, mScaleMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
internal override Quaternion Rotation
|
||||
{
|
||||
get
|
||||
{
|
||||
return Quaternion.identity;
|
||||
}
|
||||
}
|
||||
|
||||
internal override Vector3 Translation
|
||||
{
|
||||
get
|
||||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// equivalent to calling Grow and Shrink one after the other
|
||||
/// </summary>
|
||||
public void GrowAndShrink()
|
||||
{
|
||||
mStartTime = Time.time;
|
||||
mStartValue = mScaleMultiplier;
|
||||
Operation = GrowShrinkOp;
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
public bool CheckAnimationEnded( float time, AnimationCurve curve)
|
||||
{
|
||||
if (curve.length == 0)
|
||||
return true;
|
||||
bool ended = time > curve.keys[curve.length - 1].time;
|
||||
if(ended)
|
||||
{
|
||||
if (mDeactivateOnEnd)
|
||||
{
|
||||
RaiseDeactivated();
|
||||
enabled = false;
|
||||
gameObject.SetActive(false);
|
||||
mDeactivateOnEnd = false;
|
||||
}
|
||||
}
|
||||
return ended;
|
||||
}
|
||||
|
||||
private void FixEaseFunction(AnimationCurve curve)
|
||||
{
|
||||
curve.postWrapMode = WrapMode.Once;
|
||||
curve.preWrapMode = WrapMode.Once;
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
float opTime = Time.time - mStartTime;
|
||||
opTime *= TimeScale;
|
||||
float val;
|
||||
switch(Operation)
|
||||
{
|
||||
case GrowOp:
|
||||
FixEaseFunction(GrowEaseFunction);
|
||||
val = GrowEaseFunction.Evaluate(opTime);
|
||||
mScaleMultiplier = ChartCommon.SmoothLerp(mStartValue, GrowMultiplier, val);
|
||||
if (CheckAnimationEnded(opTime, GrowEaseFunction))
|
||||
{
|
||||
Operation = NoOp;
|
||||
mScaleMultiplier = GrowMultiplier;
|
||||
}
|
||||
break;
|
||||
case ShrinkOp:
|
||||
FixEaseFunction(ShrinkEaseFunction);
|
||||
val = ShrinkEaseFunction.Evaluate(opTime);
|
||||
mScaleMultiplier = ChartCommon.SmoothLerp(mStartValue, 1f, val);
|
||||
if (CheckAnimationEnded(opTime, ShrinkEaseFunction))
|
||||
{
|
||||
Operation = NoOp;
|
||||
mScaleMultiplier = 1f;
|
||||
}
|
||||
break;
|
||||
case GrowShrinkOp:
|
||||
FixEaseFunction(GrowEaseFunction);
|
||||
val = GrowEaseFunction.Evaluate(opTime);
|
||||
mScaleMultiplier = ChartCommon.SmoothLerp(mStartValue, GrowMultiplier, val);
|
||||
if (CheckAnimationEnded(opTime, GrowEaseFunction))
|
||||
{
|
||||
mScaleMultiplier = GrowMultiplier;
|
||||
Shrink();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void TriggerOut(bool deactivateOnEnd)
|
||||
{
|
||||
mDeactivateOnEnd = deactivateOnEnd;
|
||||
Shrink();
|
||||
}
|
||||
|
||||
public override void TriggerIn(bool deactivateOnEnd)
|
||||
{
|
||||
mDeactivateOnEnd = deactivateOnEnd;
|
||||
Grow();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Grows the size of the object
|
||||
/// </summary>
|
||||
public void Grow()
|
||||
{
|
||||
mStartTime = Time.time;
|
||||
mStartValue = mScaleMultiplier;
|
||||
Operation = GrowOp;
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shrinks the object back to the original size
|
||||
/// </summary>
|
||||
public void Shrink()
|
||||
{
|
||||
mStartTime = Time.time;
|
||||
mStartValue = mScaleMultiplier;
|
||||
Operation = ShrinkOp;
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68eb8a9ffb98caa4ba2dfcd1198e3c4c
|
||||
timeCreated: 1478280231
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
159
Assets/Chart And Graph/Script/ChartItem/ChartItemLerpEffect.cs
Normal file
159
Assets/Chart And Graph/Script/ChartItem/ChartItemLerpEffect.cs
Normal file
@@ -0,0 +1,159 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
public abstract class ChartItemLerpEffect : ChartItemEffect
|
||||
{
|
||||
const int NoOp = 0;
|
||||
const int GrowOp = 1;
|
||||
const int ShrinkOp = 2;
|
||||
const int GrowShrinkOp = 3;
|
||||
/// <summary>
|
||||
/// scales the time used in the easing curves
|
||||
/// </summary>
|
||||
public float TimeScale = 1f;
|
||||
/// <summary>
|
||||
/// easing function for the grow effect. when the curve is at 0 there will be no change , when the curve is at 1 the change will be equal to the GrowMultiplier property
|
||||
/// </summary>
|
||||
public AnimationCurve GrowEaseFunction = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
|
||||
/// <summary>
|
||||
/// easing function for the shrink effect. when the curve is at 0 there will be no change , when the curve is at 1 the change will be equal to the GrowMultiplier property
|
||||
/// </summary>
|
||||
public AnimationCurve ShrinkEaseFunction = AnimationCurve.EaseInOut(1f, 1f, 0f, 0f);
|
||||
|
||||
|
||||
float mStartTime = 0f;
|
||||
float mStartValue = 0f;
|
||||
int Operation = NoOp;
|
||||
bool mDeactivateOnEnd = false;
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
enabled = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// equivalent to calling Grow and Shrink one after the other
|
||||
/// </summary>
|
||||
public void GrowAndShrink()
|
||||
{
|
||||
mStartTime = Time.time;
|
||||
mStartValue = Mathf.Clamp(GetStartValue(), 0f, 1f);
|
||||
Operation = GrowShrinkOp;
|
||||
enabled = true;
|
||||
}
|
||||
public bool CheckAnimationEnded(float time, AnimationCurve curve)
|
||||
{
|
||||
if (curve.length == 0)
|
||||
return true;
|
||||
bool ended = time > curve.keys[curve.length - 1].time;
|
||||
if (ended)
|
||||
{
|
||||
if (mDeactivateOnEnd)
|
||||
{
|
||||
RaiseDeactivated();
|
||||
enabled = false;
|
||||
// gameObject.SetActive(false);
|
||||
mDeactivateOnEnd = false;
|
||||
}
|
||||
}
|
||||
return ended;
|
||||
}
|
||||
|
||||
private void FixEaseFunction(AnimationCurve curve)
|
||||
{
|
||||
curve.postWrapMode = WrapMode.Once;
|
||||
curve.preWrapMode = WrapMode.Once;
|
||||
}
|
||||
|
||||
protected abstract void ApplyLerp(float value);
|
||||
protected abstract float GetStartValue();
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
float opTime = Time.time - mStartTime;
|
||||
opTime *= TimeScale;
|
||||
float val;
|
||||
switch (Operation)
|
||||
{
|
||||
case GrowOp:
|
||||
FixEaseFunction(GrowEaseFunction);
|
||||
val = GrowEaseFunction.Evaluate(opTime);
|
||||
val = Mathf.Lerp(mStartValue, 1f, val);
|
||||
ApplyLerp(val);
|
||||
if (CheckAnimationEnded(opTime, GrowEaseFunction))
|
||||
{
|
||||
Operation = NoOp;
|
||||
ApplyLerp(1f);
|
||||
enabled = false;
|
||||
}
|
||||
break;
|
||||
case ShrinkOp:
|
||||
FixEaseFunction(ShrinkEaseFunction);
|
||||
val = ShrinkEaseFunction.Evaluate(opTime);
|
||||
val = Mathf.Lerp(mStartValue, 0f, val);
|
||||
ApplyLerp(val);
|
||||
if (CheckAnimationEnded(opTime, ShrinkEaseFunction))
|
||||
{
|
||||
Operation = NoOp;
|
||||
ApplyLerp(0f);
|
||||
enabled = false;
|
||||
}
|
||||
break;
|
||||
case GrowShrinkOp:
|
||||
FixEaseFunction(GrowEaseFunction);
|
||||
val = GrowEaseFunction.Evaluate(opTime);
|
||||
val = Mathf.Lerp(mStartValue, 1f, val);
|
||||
ApplyLerp(val);
|
||||
if (CheckAnimationEnded(opTime, GrowEaseFunction))
|
||||
{
|
||||
ApplyLerp(1f);
|
||||
Shrink();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void TriggerOut(bool deactivateOnEnd)
|
||||
{
|
||||
mDeactivateOnEnd = deactivateOnEnd;
|
||||
Shrink();
|
||||
}
|
||||
|
||||
public override void TriggerIn(bool deactivateOnEnd)
|
||||
{
|
||||
mDeactivateOnEnd = deactivateOnEnd;
|
||||
Grow();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Grows the size of the object
|
||||
/// </summary>
|
||||
public void Grow()
|
||||
{
|
||||
mStartTime = Time.time;
|
||||
mStartValue = Mathf.Clamp(GetStartValue(), 0f, 1f);
|
||||
Operation = GrowOp;
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shrinks the object back to the original size
|
||||
/// </summary>
|
||||
public void Shrink()
|
||||
{
|
||||
mStartTime = Time.time;
|
||||
mStartValue = Mathf.Clamp(GetStartValue(), 0f, 1f);
|
||||
Operation = ShrinkOp;
|
||||
enabled = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e51efaa064659f14888467bede716d1f
|
||||
timeCreated: 1492087245
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// lerps the material changes of the chart item. This is used to achive smooth transition between the chart item colors.
|
||||
/// </summary>
|
||||
class ChartItemMaterialLerpEffect : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// the speed of the interpolation between the materials
|
||||
/// </summary>
|
||||
public float LerpTime = 1f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8feef96b2dc87824c82b7d0425846b72
|
||||
timeCreated: 1478372950
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
100
Assets/Chart And Graph/Script/ChartItem/ChartItemTextBlend.cs
Normal file
100
Assets/Chart And Graph/Script/ChartItem/ChartItemTextBlend.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
class ChartItemTextBlend : ChartItemLerpEffect
|
||||
{
|
||||
|
||||
Text mText;
|
||||
Shadow[] mShadows;
|
||||
Dictionary<UnityEngine.Object, float> mInitialValues = new Dictionary<UnityEngine.Object, float>();
|
||||
CanvasRenderer mRenderer = null;
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
mText = GetComponent<Text>();
|
||||
mShadows = GetComponents<Shadow>();
|
||||
foreach(Shadow s in mShadows)
|
||||
mInitialValues.Add(s, s.effectColor.a);
|
||||
ApplyLerp(0f);
|
||||
|
||||
}
|
||||
internal override Quaternion Rotation
|
||||
{
|
||||
get
|
||||
{
|
||||
return Quaternion.identity;
|
||||
}
|
||||
}
|
||||
|
||||
internal override Vector3 ScaleMultiplier
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Vector3(1f, 1f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
internal override Vector3 Translation
|
||||
{
|
||||
get
|
||||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected override float GetStartValue()
|
||||
{
|
||||
if (mText != null)
|
||||
return mText.color.a;
|
||||
return 0f;
|
||||
}
|
||||
|
||||
CanvasRenderer EnsureRenderer()
|
||||
{
|
||||
if (mRenderer == null)
|
||||
mRenderer = GetComponent<CanvasRenderer>();
|
||||
return mRenderer;
|
||||
}
|
||||
|
||||
protected override void ApplyLerp(float value)
|
||||
{
|
||||
for (int i = 0; i < mShadows.Length; i++)
|
||||
{
|
||||
Shadow s = mShadows[i];
|
||||
float inital;
|
||||
if (mInitialValues.TryGetValue(s, out inital) == false)
|
||||
continue;
|
||||
Color c = s.effectColor;
|
||||
c.a = Mathf.Lerp(0f, inital, value);
|
||||
s.effectColor = c;
|
||||
}
|
||||
if (mText != null)
|
||||
{
|
||||
Color c = mText.color;
|
||||
c.a = Mathf.Clamp(value,0f,1f);
|
||||
mText.color = c;
|
||||
CanvasRenderer rend = EnsureRenderer();
|
||||
if (rend != null)
|
||||
{
|
||||
if (value <= 0f)
|
||||
{
|
||||
if (rend.cull == false)
|
||||
rend.cull = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rend.cull == true)
|
||||
rend.cull = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1156d6a111e4bee469a4b875fa038ded
|
||||
timeCreated: 1492087245
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user