This commit is contained in:
정영민
2025-02-20 09:59:37 +09:00
parent 4dfe902e02
commit 2dd5d814a7
6244 changed files with 4671685 additions and 5 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 894f48b28be16f0439d3ccaefb061b19
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BarGraph.VittorCloud
{
public class BarGorup : MonoBehaviour
{
#region publicVariables
public List<GameObject> ListOfBar;
#endregion
#region UnityCallBacks
private void Awake()
{
ListOfBar = new List<GameObject>();
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9ee7753db653c444987211303d5f4d85
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,476 @@
using Uitility.VittorCloud;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using System.Linq.Expressions;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace BarGraph.VittorCloud
{
#region CustomEventsDeclaration
[Serializable]
public class OnBarPointerDownEvent : UnityEvent<GameObject>
{
}
[Serializable]
public class OnBarPointerUpEvent : UnityEvent<GameObject>
{
}
[Serializable]
public class OnBarHoverEnterEvent : UnityEvent<GameObject>
{
}
[Serializable]
public class OnBarHoverExitEvent : UnityEvent<GameObject>
{
}
#endregion
[Serializable]
public class BarGraphDataSet
{
public string GroupName = "groupname";
public Color barColor;
public Material barMaterial;
public List<XYBarValues> ListOfBars;
}
[Serializable]
public class XYBarValues
{
public string XValue; //xvalue
public float YValue = 0; // yvalue
}
public class BarGraphGenerator : MonoBehaviour
{
#region publicVariables
public enum AnimatioType { None = 0, OneByOne = 1, allTogether = 2, animationWithGradient = 3 };
public enum BarColor { SolidColor = 1, CustumMaterial = 2, HeightWiseGradient = 3 };
//[Header("Graph Settings")]
public int MaxHeight = 10;
public float xStart = 1;
public float yStart = 1;
public float zStart = 1;
public float segmentSizeOnXaxis = 1;
public float segmentSizeOnYaxis = 1;
public float segmentSizeOnZaxis = 1;
public float offsetBetweenXRow = 0;
public float offsetBetweenZRow = 0;
[Header("Graph Animation Settings")]
[Range(0, 15)]
public float animationSpeed = 1.5f;
public AnimatioType graphAnimation = AnimatioType.OneByOne;
//[Header("Bar Settings")]
public GameObject barPrefab;
public BarColor barColorProperty = BarColor.SolidColor;
public float barScaleFactor = 1;
public BarGraphManager GraphRef;
[HideInInspector]
public int yMaxValue;
[HideInInspector]
public int yMinValue;
public Gradient HeightWiseGradient = new Gradient();
#endregion
#region privateVariables
private List<BarGraphDataSet> ListOfDataSet;
int zMaxSize;
int xMaxSize;
int yMaxSize;
List<string> xvalues = new List<string>();
List<float> yvalues = new List<float>();
List<string> zvalues = new List<string>();
bool modifyData = false;
BarGraphManager Graph;
bool barCompleted = false;
Color gredientStartColor = Color.white;
#endregion
#region CustomEvents
public OnBarPointerDownEvent OnBarPointerDown;
public OnBarPointerUpEvent OnBarPointerUp;
public OnBarHoverEnterEvent OnBarHoverEnter;
public OnBarHoverExitEvent OnBarHoverExit;
public UnityEvent OnInitialGraphCompleted;
#endregion
#region UnityCallBacks
public void Start()
{
if (OnInitialGraphCompleted == null)
OnInitialGraphCompleted = new UnityEvent();
if (OnBarPointerDown == null)
OnBarPointerDown = new OnBarPointerDownEvent();
if (OnBarPointerUp == null)
OnBarPointerUp = new OnBarPointerUpEvent();
if (OnBarHoverEnter == null)
OnBarHoverEnter = new OnBarHoverEnterEvent();
if (OnBarHoverExit == null)
OnBarHoverExit = new OnBarHoverExitEvent();
if (graphAnimation == AnimatioType.animationWithGradient)
barColorProperty = BarColor.HeightWiseGradient;
if (barColorProperty == BarColor.HeightWiseGradient)
gredientStartColor = HeightWiseGradient.Evaluate(0);
}
private void OnDisable()
{
if (Graph != null)
Graph.GraphUpdated -= OnGraphAnimationCompleted;
}
#endregion
#region GenerateGraphBox
public void GeneratBarGraph(List<BarGraphDataSet> dataSet)
{
if (dataSet == null)
{
return;
}
ListOfDataSet = dataSet;
xMaxSize = ListOfDataSet[0].ListOfBars.Count;
yMaxSize = MaxHeight;
zMaxSize = ListOfDataSet.Count;
InitializeGraph();
AssignGraphAxisName();
ParseTheDataset();
if ((int)graphAnimation == 1 || (int)graphAnimation == 3)
StartCoroutine(CreateBarsWithAnimTypeOneOrThree());
else
CreateBarsWithAnimTypeTwo();
}
private void ParseTheDataset()
{
if (ListOfDataSet.Count <= 0)
{
Debug.LogError("No data set inserted!!");
return;
}
for (int i = 0; i < ListOfDataSet.Count; i++)
{
if (ListOfDataSet[i].ListOfBars.Count <= 0)
{
Debug.LogError("No data set inserted at" + ListOfDataSet[i].GroupName);
return;
}
for (int j = 0; j < ListOfDataSet[i].ListOfBars.Count; j++)
{
zvalues.Add(ListOfDataSet[i].GroupName);
xvalues.Add(ListOfDataSet[i].ListOfBars[j].XValue);
yvalues.Add(ListOfDataSet[i].ListOfBars[j].YValue);
}
}
ValidateRange();
Graph.FetchYPointValues(yMinValue, yMaxValue);
}
public void ValidateRange()
{
int min;
int max;
min = (int)MathExtension.GetMinValue(yvalues);
max = (int)MathExtension.GetMaxValue(yvalues);
int range = max - min;
yMinValue = MathExtension.Round(min, range);
yMaxValue = MathExtension.Round(max, range);
// Debug.Log("yMinValue" + yMinValue);
// Debug.Log("yMaxValue" + yMaxValue);
if (yMinValue > min)
{
yMinValue = yMinValue / 2;
}
if (yMaxValue < max)
{
yMaxValue = yMaxValue * 2;
}
if (yMaxValue <= yMinValue || yMaxValue < max)
{
yMaxValue = max;
}
// Debug.Log("yMinValue" + yMinValue);
// Debug.Log("yMaxValue" + yMaxValue);
//if (yMinValue < yMaxValue / 2)
//{
// // yMinValue = 0;
//}
}
void InitializeGraph()
{
Graph = Instantiate(GraphRef, transform.position, Quaternion.identity);
Graph.transform.rotation = this.transform.rotation;
Graph.transform.parent = this.transform;
float XLength = xStart + ((xMaxSize - 1) * segmentSizeOnXaxis);
float YLength = yStart + ((yMaxSize - 1) * segmentSizeOnYaxis);
float ZLength = zStart + ((zMaxSize - 1) * segmentSizeOnZaxis);
Graph.setBarScale(barScaleFactor);
Graph.InitGraphBox(XLength, YLength, ZLength, segmentSizeOnXaxis, segmentSizeOnYaxis, segmentSizeOnZaxis);
Graph.SetBarRef(barPrefab);
Graph.InitXAxis(xMaxSize, xStart, segmentSizeOnXaxis, offsetBetweenXRow);
Graph.InitYAxis(yMaxSize, yStart, segmentSizeOnYaxis);
Graph.InitZAxis(zMaxSize, zStart, segmentSizeOnZaxis, offsetBetweenZRow, xStart, segmentSizeOnXaxis);
Graph.GraphUpdated += OnGraphAnimationCompleted;
}
public void AssignGraphAxisName()
{
for (int i = 0; i < ListOfDataSet.Count; i++)
{
for (int j = 0; j < ListOfDataSet[i].ListOfBars.Count; j++)
{
Graph.AssignAxisName(j, i, ListOfDataSet[i].ListOfBars[j].XValue, ListOfDataSet[i].GroupName);
}
}
}
public IEnumerator CreateBarsWithAnimTypeOneOrThree()
{
for (int i = 0; i < ListOfDataSet.Count; i++)
{
for (int j = 0; j < ListOfDataSet[i].ListOfBars.Count; j++)
{
float yscaleFactor = (((yMaxSize - 1) * segmentSizeOnYaxis) + yStart) / (yMaxValue - yMinValue);
if (barColorProperty == BarColor.SolidColor)
yield return StartCoroutine(Graph.GenerateGraphBarWithAnimTypeOne(j, i, ListOfDataSet[i].ListOfBars[j].YValue, yscaleFactor, animationSpeed, yMinValue, xMaxSize, ListOfDataSet[i].barColor));
else if (barColorProperty == BarColor.HeightWiseGradient)
{
float time = (ListOfDataSet[i].ListOfBars[j].YValue - yMinValue) / (yMaxValue - yMinValue);
Color barcolor = HeightWiseGradient.Evaluate(time);
if (graphAnimation == AnimatioType.animationWithGradient)
{
yield return StartCoroutine(Graph.GenerateGraphBarWithAnimTypeThree(j, i, ListOfDataSet[i].ListOfBars[j].YValue, yscaleFactor, animationSpeed, yMinValue, xMaxSize, barcolor, gredientStartColor));
}
else
yield return StartCoroutine(Graph.GenerateGraphBarWithAnimTypeOne(j, i, ListOfDataSet[i].ListOfBars[j].YValue, yscaleFactor, animationSpeed, yMinValue, xMaxSize, barcolor));
}
else
yield return StartCoroutine(Graph.GenerateGraphBarWithAnimTypeOne(j, i, ListOfDataSet[i].ListOfBars[j].YValue, yscaleFactor, animationSpeed, yMinValue, xMaxSize, ListOfDataSet[i].barMaterial));
yield return new WaitForSeconds(0.2f);
}
}
Graph.GraphUpdated();
yield return null;
}
public void CreateBarsWithAnimTypeTwo()
{
for (int i = 0; i < ListOfDataSet.Count; i++)
{
for (int j = 0; j < ListOfDataSet[i].ListOfBars.Count; j++)
{
float yscaleFactor = (((yMaxSize - 1) * segmentSizeOnYaxis) + yStart) / (yMaxValue - yMinValue);
if (barColorProperty == BarColor.SolidColor)
Graph.GenerateBarWithAnimTypeTwo(j, i, ListOfDataSet[i].ListOfBars[j].YValue, yscaleFactor, animationSpeed, yMinValue, xMaxSize, ListOfDataSet[i].barColor);
else if (barColorProperty == BarColor.HeightWiseGradient)
{
float time = (ListOfDataSet[i].ListOfBars[j].YValue - yMinValue) / (yMaxValue - yMinValue);
Color barcolor = HeightWiseGradient.Evaluate(time);
Graph.GenerateBarWithAnimTypeTwo(j, i, ListOfDataSet[i].ListOfBars[j].YValue, yscaleFactor, animationSpeed, yMinValue, xMaxSize, barcolor);
}
else
Graph.GenerateBarWithAnimTypeTwo(j, i, ListOfDataSet[i].ListOfBars[j].YValue, yscaleFactor, animationSpeed, yMinValue, xMaxSize, ListOfDataSet[i].barMaterial);
}
}
StartCoroutine(Graph.AnimateBarsWithAnimTypeTwo(animationSpeed));
}
#endregion
#region testing Methods
public void AddNewDataSet(int dataSetIndex, int xyValueIndex, float yValue)
{
if (modifyData)
{
modifyData = false;
ListOfDataSet[dataSetIndex].ListOfBars[xyValueIndex].YValue = yValue;
float yscaleFactor = (yMaxSize * segmentSizeOnYaxis) / (yMaxValue - yMinValue);
if (barColorProperty == BarColor.HeightWiseGradient)
{
float time = (yValue - yMinValue) / (yMaxValue - yMinValue);
Color barcolor = HeightWiseGradient.Evaluate(time);
if (graphAnimation == AnimatioType.animationWithGradient)
{
Graph.UpdateBarHeight(xyValueIndex, dataSetIndex, ListOfDataSet[dataSetIndex].ListOfBars[xyValueIndex].YValue, yscaleFactor, animationSpeed, yMinValue, barcolor, gredientStartColor);
}
else
{
Graph.UpdateBarHeight(xyValueIndex, dataSetIndex, ListOfDataSet[dataSetIndex].ListOfBars[xyValueIndex].YValue, yscaleFactor, animationSpeed, yMinValue, barcolor);
}
}
else
{
Graph.UpdateBarHeight(xyValueIndex, dataSetIndex, ListOfDataSet[dataSetIndex].ListOfBars[xyValueIndex].YValue, yscaleFactor, animationSpeed, yMinValue);
}
}
}
public void OnGraphAnimationCompleted()
{
modifyData = true;
if (!barCompleted)
{
barCompleted = true;
OnInitialGraphCompleted.Invoke();
}
}
public void ModifyGraph()
{
for (int i = 0; i < ListOfDataSet.Count; i++)
{
xvalues.RemoveAt(0);
yvalues.RemoveAt(0);
int lastIndex = ListOfDataSet[i].ListOfBars.Count - 1;
xvalues.Add(ListOfDataSet[i].ListOfBars[lastIndex].XValue);
yvalues.Add(ListOfDataSet[i].ListOfBars[lastIndex].YValue);
Graph.RemoveAndShiftXpoints(ListOfDataSet[i].ListOfBars[lastIndex].XValue);
float yscaleFactor = (yMaxSize * segmentSizeOnYaxis) / (yMaxValue - yMinValue);
if (barColorProperty == BarColor.SolidColor)
Graph.GenerateBarWithAnimTypeTwo(lastIndex, i, ListOfDataSet[i].ListOfBars[lastIndex].YValue, yscaleFactor, animationSpeed, yMinValue, xMaxSize, ListOfDataSet[i].barColor);
else
Graph.GenerateBarWithAnimTypeTwo(lastIndex, i, ListOfDataSet[i].ListOfBars[lastIndex].YValue, yscaleFactor, animationSpeed, yMinValue, xMaxSize, ListOfDataSet[i].barMaterial);
}
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1ddead78b26f39d4a8126f3099e140c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,412 @@
using Graph.VittorCloud;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BarGraph.VittorCloud
{
public class BarGraphManager : GraphBox
{
#region PublicVariables
public Action GraphUpdated;
#endregion
#region PrivateVariables
GameObject barRef;
BarGraphGenerator graphGenerator;
#endregion
#region UnityCallBacks
public void Awake()
{
base.Awake();
}
public void Start()
{
if (barRef == null)
Debug.LogError("Bar Prefabe is Empty!! Please assign the bar prefabe to GraphBox.");
graphGenerator = GetComponentInParent<BarGraphGenerator>();
}
#endregion
#region BarGraph Custom methods
public void SetBarRef(GameObject bar) {
barRef = bar;
}
#region AnimationTypeOne
public IEnumerator GenerateGraphBarWithAnimTypeOne(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, int xMax, Color barColor)
{
if (barRef == null)
yield return null;
barParent.transform.localScale = Vector3.one;
//
GameObject bar = GameObject.Instantiate(barRef, transform.position, transform.rotation);
bar.transform.parent = ListOfGroups[zIndex].transform;
//Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.position.x, 0, ListOfZPoints[zIndex].transform.position.z);
// Debug.Log("Yes I am calling -----");
Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.localPosition.x, 0, 0);
bar.transform.localPosition = pos;
bar.transform.localScale = bar.transform.localScale * graphScaleFactor;
BarProperty barProperty = bar.GetComponent<BarProperty>();
SetBarProperties(barProperty);
barProperty.SetBarColor(barColor);
ListOfGroups[zIndex].ListOfBar.Add(bar);
float yscale = (yValue - ymin) * scaleFactor;
yield return StartCoroutine(AnimateBarsWithAnimTypeOne(barProperty, yscale, yValue, animSpeed, false));
yield return new WaitForEndOfFrame();
}
public IEnumerator GenerateGraphBarWithAnimTypeOne(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, int xMax, Material barMaterial)
{
if (barRef == null)
yield return null;
barParent.transform.localScale = Vector3.one;
GameObject bar = GameObject.Instantiate(barRef, transform.position, transform.rotation);
bar.transform.parent = ListOfGroups[zIndex].transform;
//Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.position.x, 0, ListOfZPoints[zIndex].transform.position.z);
// Debug.Log("Yes I am calling -----");
Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.localPosition.x, 0, 0);
bar.transform.localPosition = pos;
bar.transform.localScale = bar.transform.localScale * graphScaleFactor;
ListOfGroups[zIndex].ListOfBar.Add(bar);
BarProperty barProperty = bar.GetComponent<BarProperty>();
SetBarProperties(barProperty);
if (barMaterial != null)
barProperty.SetBarMat(barMaterial);
float yscale = (yValue - ymin) * scaleFactor;
yield return StartCoroutine(AnimateBarsWithAnimTypeOne(bar.GetComponent<BarProperty>(), yscale, yValue, animSpeed, false));
yield return new WaitForEndOfFrame();
}
public IEnumerator AnimateBarsWithAnimTypeOne(BarProperty bar, float barScale, float yValue, float animSpeed, bool isUpdating)
{
while (true)
{
Vector3 targetScale = new Vector3(bar.transform.localScale.x, barScale, bar.transform.localScale.z);
BarProperty barProperty = bar.GetComponent<BarProperty>();
if (bar.transform.localScale.y > targetScale.y)
{
Vector3 scale = bar.transform.localScale - new Vector3(0, Time.deltaTime * animSpeed, 0);
scale.y = Mathf.Clamp(scale.y, targetScale.y, yValue);
Debug.Log($"y scale {scale.y} traget scale {targetScale.y} yvalue {yValue}");
bar.transform.localScale = scale;
if (bar.transform.localScale.y <= targetScale.y)
{
barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
break;
}
}
else
{
Vector3 scale = bar.transform.localScale + new Vector3(0, Time.deltaTime * animSpeed, 0);
scale.y = Mathf.Clamp(scale.y, 0, targetScale.y);
Debug.Log($"y scale {scale.y} traget scale {targetScale.y} yvalue {yValue}");
bar.transform.localScale = scale;
if (bar.transform.localScale.y >= targetScale.y)
{
barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
break;
}
}
yield return new WaitForEndOfFrame();
}
if (isUpdating)
GraphUpdated();
yield return new WaitForEndOfFrame();
}
#endregion
#region AnimationTypeTwo
public void GenerateBarWithAnimTypeTwo(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, int xMax, Color barColor)
{
if (barRef == null)
return;
GameObject bar = GameObject.Instantiate(barRef, transform.position, transform.rotation);
bar.transform.parent = ListOfGroups[zIndex].transform;
//Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.position.x, 0, ListOfZPoints[zIndex].transform.position.z);
// Debug.Log("Yes I am calling -----");
Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.localPosition.x, 0, 0);
bar.transform.localPosition = pos;
bar.transform.localScale = bar.transform.localScale * graphScaleFactor;
BarProperty barProperty = bar.GetComponent<BarProperty>();
SetBarProperties(barProperty);
barProperty.SetBarColor(barColor);
barProperty.SetBarLabel(yValue.ToString(), graphScaleFactor);
float yscale = (yValue - ymin) * scaleFactor;
bar.transform.localScale = new Vector3(bar.transform.localScale.x, yscale, bar.transform.localScale.z);
ListOfGroups[zIndex].ListOfBar.Add(bar);
}
public void GenerateBarWithAnimTypeTwo(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, int xMax, Material barMaterial)
{
if (barRef == null)
return;
GameObject bar = GameObject.Instantiate(barRef, transform.position, transform.rotation);
bar.transform.parent = ListOfGroups[zIndex].transform;
//Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.position.x, 0, ListOfZPoints[zIndex].transform.position.z);
// Debug.Log("Yes I am calling -----");
Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.localPosition.x, 0, 0);
bar.transform.localPosition = pos;
bar.transform.localScale = bar.transform.localScale * graphScaleFactor;
BarProperty barProperty = bar.GetComponent<BarProperty>();
SetBarProperties(barProperty);
if (barMaterial != null)
barProperty.SetBarMat(barMaterial);
barProperty.SetBarLabel(yValue.ToString(), graphScaleFactor);
float yscale = (yValue - ymin) * scaleFactor;
bar.transform.localScale = new Vector3(bar.transform.localScale.x, yscale, bar.transform.localScale.z);
ListOfGroups[zIndex].ListOfBar.Add(bar);
}
public IEnumerator AnimateBarsWithAnimTypeTwo(float animSpeed)
{
barParent.transform.localScale = new Vector3(1, 0, 1);
while (true)
{
Vector3 scale = barParent.transform.localScale + new Vector3(0, Time.deltaTime * animSpeed, 0);
scale.y = Mathf.Clamp(scale.y, 0, 1);
barParent.transform.localScale = scale;
if (barParent.transform.localScale.y >= 1)
{
foreach (BarProperty bar in barParent.GetComponentsInChildren<BarProperty>())
bar.GetComponent<BarProperty>().SetLabelEnabel();
break;
}
yield return new WaitForEndOfFrame();
}
GraphUpdated();
yield return new WaitForEndOfFrame();
}
#endregion
#region AnimtionTypeThree
public IEnumerator GenerateGraphBarWithAnimTypeThree(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, int xMax, Color barColor, Color barStartColor)
{
if (barRef == null)
yield return null;
barParent.transform.localScale = Vector3.one;
GameObject bar = GameObject.Instantiate(barRef, transform.position, transform.rotation);
bar.transform.parent = ListOfGroups[zIndex].transform;
// Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.localPosition.x, 0, ListOfZPoints[zIndex].transform.localPosition.z);
Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.localPosition.x, 0, 0);
bar.transform.localPosition = pos;
bar.transform.localScale = bar.transform.localScale * graphScaleFactor;
BarProperty barProperty = bar.GetComponent<BarProperty>();
SetBarProperties(barProperty);
barProperty.SetBarColor(barStartColor);
ListOfGroups[zIndex].ListOfBar.Add(bar);
float yscale = (yValue - ymin) * scaleFactor;
yield return StartCoroutine(AnimateBarsWithAnimTypeThree(bar.GetComponent<BarProperty>(), yscale, yValue, animSpeed, false, barColor, barStartColor));
yield return new WaitForEndOfFrame();
}
public IEnumerator AnimateBarsWithAnimTypeThree(BarProperty bar, float barScale, float yValue, float animSpeed, bool isUpdating, Color barColor, Color barStartColor)
{
while (true)
{
BarProperty barProperty = bar.GetComponent<BarProperty>();
Color barCol = Color.Lerp(barProperty.GetBarColor(), barColor, Time.deltaTime * animSpeed * 0.4f);
barProperty.SetBarColor(barCol);
Vector3 targetScale = new Vector3(bar.transform.localScale.x, barScale, bar.transform.localScale.z);
if (bar.transform.localScale.y > targetScale.y)
{
Vector3 scale = bar.transform.localScale - new Vector3(0, Time.deltaTime * animSpeed, 0);
scale.y = Mathf.Clamp(scale.y, targetScale.y, yValue);
bar.transform.localScale = scale;
if (bar.transform.localScale.y <= targetScale.y)
{
barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
barProperty.SetBarColor(barColor);
break;
}
}
else
{
Vector3 scale = bar.transform.localScale + new Vector3(0, Time.deltaTime * animSpeed, 0);
scale.y = Mathf.Clamp(scale.y, 0, targetScale.y);
bar.transform.localScale = scale;
if (bar.transform.localScale.y >= targetScale.y)
{
barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
barProperty.SetBarColor(barColor);
break;
}
}
yield return new WaitForEndOfFrame();
}
if (isUpdating)
GraphUpdated();
yield return new WaitForEndOfFrame();
}
#endregion
#region UpdateGraph
public void UpdateBarHeight(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin)
{
GameObject bar = ListOfGroups[zIndex].ListOfBar[xIndex];
float yscale = (yValue - ymin) * scaleFactor;
BarProperty barProperty = bar.GetComponent<BarProperty>();
barProperty.LabelContainer.SetActive(false);
StartCoroutine(AnimateBarsWithAnimTypeOne(barProperty, yscale, yValue, animSpeed, true));
}
public void UpdateBarHeight(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, Color barColor)
{
GameObject bar = ListOfGroups[zIndex].ListOfBar[xIndex];
float yscale = (yValue - ymin) * scaleFactor;
BarProperty barProperty = bar.GetComponent<BarProperty>();
barProperty.LabelContainer.SetActive(false);
barProperty.SetBarColor(barColor);
StartCoroutine(AnimateBarsWithAnimTypeOne(barProperty, yscale, yValue, animSpeed, true));
}
public void UpdateBarHeight(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, Color barColor, Color barStartColor)
{
GameObject bar = ListOfGroups[zIndex].ListOfBar[xIndex];
BarProperty barProperty = bar.GetComponent<BarProperty>();
float yscale = (yValue - ymin) * scaleFactor;
barProperty.LabelContainer.SetActive(false);
StartCoroutine(AnimateBarsWithAnimTypeThree(barProperty, yscale, yValue, animSpeed, true, barColor, barStartColor));
}
#endregion
public void RemoveAndShiftXpoints(string xValue)
{
for (int i = 0; i < ListOfXPoint.Count - 1; i++)
{
Debug.Log("Cont " + i + " " + ListOfXPoint[i].labelText + " " + ListOfXPoint[i + 1].labelText);
ListOfXPoint[i].labelText = ListOfXPoint[i + 1].labelText;
}
ListOfXPoint[ListOfXPoint.Count - 1].labelText = xValue.ToString();
}
public void SetBarProperties(BarProperty barProperty)
{
barProperty.barClickEvents.PointerDownOnBar += OnBarPointerDown;
barProperty.barClickEvents.PointerUpOnBar += OnBarPointerUp;
barProperty.barClickEvents.PointerEnterOnBar += OnBarPointerEnter;
barProperty.barClickEvents.PointerExitOnBar += OnBarPointerExit;
}
#endregion
#region ClickEvents
public void OnBarPointerDown(GameObject Clickedbar)
{
if (graphGenerator != null)
graphGenerator.OnBarPointerDown.Invoke(Clickedbar);
}
public void OnBarPointerUp(GameObject Clickedbar)
{
if (graphGenerator != null)
graphGenerator.OnBarPointerUp.Invoke(Clickedbar);
}
public void OnBarPointerEnter(GameObject Clickedbar)
{
if (graphGenerator != null)
graphGenerator.OnBarHoverEnter.Invoke(Clickedbar);
}
public void OnBarPointerExit(GameObject Clickedbar)
{
if (graphGenerator != null)
graphGenerator.OnBarHoverExit.Invoke(Clickedbar);
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8208f14e2e2f579429214bdc68f5e64e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 300
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace BarGraph.VittorCloud
{
public class BarMouseClick : MonoBehaviour
{
#region PublicVariables
public Vector3 barScale;
public Outline outline;
public Action<GameObject> PointerDownOnBar;
public Action<GameObject> PointerUpOnBar;
public Action<GameObject> PointerEnterOnBar;
public Action<GameObject> PointerExitOnBar;
#endregion
#region PrivateVariables
GameObject bar;
#endregion
#region UnityCallBacks
private void Awake()
{
bar = transform.parent.gameObject;
}
// Start is called before the first frame update
void Start()
{
barScale = transform.localScale;
outline.enabled = false;
}
#region UnityMouseEvents
public void OnMouseDown()
{
transform.localScale = transform.localScale + new Vector3(0.15f, 0, 0.15f);
outline.enabled = true;
PointerDownOnBar(bar);
}
public void OnMouseUp()
{
transform.localScale = barScale;
outline.enabled = false;
PointerUpOnBar(bar);
}
public void OnMouseEnter()
{
transform.localScale = transform.localScale + new Vector3(0.15f, 0, 0.15f);
PointerEnterOnBar(bar);
// outline.enabled = true;
}
public void OnMouseExit()
{
transform.localScale = barScale;
outline.enabled = false;
PointerExitOnBar(bar);
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17bd66aed2e9f8047aeb34c5e609c1d7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,113 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
namespace BarGraph.VittorCloud
{
public class BarProperty : MonoBehaviour
{
#region publicVariable
public TextMeshPro BarLabel;
public GameObject LabelContainer;
private string barValue;
public MeshRenderer barMesh;
public BarMouseClick barClickEvents;
float ScaleFactor;
#endregion
#region privateVariables
float originalYscale = 0;
public string BarValue { get => barValue; set => barValue = value; }
#endregion
#region UnityCallBacks
private void Awake()
{
// Debug.Log("SetBarLabelVisible : " + LabelContainer.transform.localScale.y, this.gameObject);
originalYscale = LabelContainer.transform.localScale.y;
Debug.Log("originalYscale : " + LabelContainer.transform.lossyScale.y, this.gameObject);
LabelContainer.SetActive(false);
}
public void OnEnable()
{
LabelContainer.SetActive(false);
}
#endregion
#region Customfunctions
public void SetBarLabelVisible(string value, float scaleFactor)
{
BarLabel.text = value;
LabelContainer.SetActive(true);
Debug.Log("SetBarLabelVisible : " + LabelContainer.transform.localScale.y + " : " + transform.localScale.y, this.gameObject);
if (transform.localScale.y == 0)
LabelContainer.transform.localScale = new Vector3(LabelContainer.transform.localScale.x, originalYscale * scaleFactor/ transform.localScale.x, LabelContainer.transform.localScale.z);
else
LabelContainer.transform.localScale = new Vector3(LabelContainer.transform.localScale.x, originalYscale * scaleFactor / transform.localScale.y, LabelContainer.transform.localScale.z);
}
public void SetBarLabel(string value, float factor)
{
BarLabel.text = value;
LabelContainer.SetActive(false);
ScaleFactor = factor;
}
public void SetLabelEnabel()
{
Debug.Log("SetBarLabelVisible : " + LabelContainer.transform.localScale.y + " : " + transform.localScale. y, this.gameObject);
if (transform.localScale.y == 0)
LabelContainer.transform.localScale = new Vector3(LabelContainer.transform.localScale.x, originalYscale / (transform.localScale.x ), LabelContainer.transform.localScale.z);
else
LabelContainer.transform.localScale = new Vector3(LabelContainer.transform.localScale.x , originalYscale * ScaleFactor / transform.localScale.y, LabelContainer.transform.localScale.z);
LabelContainer.SetActive(true);
}
public void SetBarColor(Color barColor)
{
barMesh.material.color = barColor;
}
public Color GetBarColor()
{
return barMesh.material.color;
}
public void SetBarMat(Material barMat)
{
barMesh.material = barMat;
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 21cf68c11bd68734f8c13ab4b2951f6b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b33454238919d6f4ea9bbb51a14527cc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,324 @@
using BarGraph.VittorCloud;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Graph.VittorCloud
{
public class GraphBox : MonoBehaviour
{
#region publicVariables
public GameObject XAxis, YAxis, ZAxis;
public GraphPoint XPoint, YPoint, ZPoint;
public GameObject XYPlane, XZPlane, YZPlane;
public GameObject barParent;
public float planeSizeOffset = 1;
public GameObject horizontalGroup;
#endregion
#region privateVariables
protected List<GraphPoint> ListOfXPoint;
protected List<GraphPoint> ListOfYPoints;
protected List<GraphPoint> ListOfZPoints;
public List<BarGorup> ListOfGroups;
protected float XpointCount;
protected float YpointCount;
protected float ZpointCount;
protected float graphScaleFactor;
float XLength;
float YLength;
float ZLength;
float xOffset;
float yOffset;
float zOffset;
#endregion
#region UnityCallBacks
// Start is called before the first frame update
public void Awake()
{
ListOfXPoint = new List<GraphPoint>();
ListOfYPoints = new List<GraphPoint>();
ListOfZPoints = new List<GraphPoint>();
ListOfGroups = new List<BarGorup>();
}
// Update is called once per frame
void Update()
{
}
#endregion
#region CustomeGraphBehaviours
public void setBarScale(float scaleFactorvalue)
{
graphScaleFactor = scaleFactorvalue;
}
public void InitGraphBox(float xLength, float yLength, float zLength, float xSegment, float ySegment, float zSegment)
{
XLength = xLength;
YLength = yLength;
ZLength = zLength;
xOffset = xSegment == 0 ? XLength : xSegment;
yOffset = ySegment == 0 ? YLength : ySegment;
zOffset = zSegment == 0 ? ZLength : zSegment;
XYPlane.transform.localScale = new Vector3(XLength + xOffset, YLength + yOffset, XYPlane.transform.localScale.z);
XZPlane.transform.localScale = new Vector3(XLength + xOffset, XZPlane.transform.localScale.y, ZLength + zOffset);
YZPlane.transform.localScale = new Vector3(YZPlane.transform.localScale.x, YLength + yOffset, ZLength + zOffset);
barParent.transform.rotation = transform.rotation;
////gameObject.AddComponent<BarGraphManager>();
}
public void InitXAxis(int xMaxSize, float xStart, float xSegment, float xRowOffset)
{
XAxis.transform.localScale = new Vector3(XLength + xSegment, XAxis.transform.localScale.y, XAxis.transform.localScale.z);
if (xSegment == 0)
{
XpointCount = xMaxSize;
}
else
{
XpointCount = ((XLength - xStart) / xSegment) + 1;
}
for (int i = 0; i < XpointCount; i++)
{
float distance = 1;
Vector3 pos;
if (i == 0)
{
distance = xStart;
pos = transform.localPosition + new Vector3(distance, 0, 0);
}
else
{
distance = xSegment;
pos = ListOfXPoint[i - 1].transform.localPosition + new Vector3(distance, 0, 0);
}
GraphPoint temp = Instantiate(XPoint, transform.position, transform.rotation);
temp.transform.parent = transform;
temp.transform.localPosition = pos;
temp.transform.localScale = temp.transform.localScale * graphScaleFactor;
temp.labelContainer.localPosition= new Vector3(0, 0, -(ZLength + (1.8f * zOffset)))/ graphScaleFactor;
ListOfXPoint.Add(temp);
}
}
public void InitYAxis(int yMaxSize, float yStart, float ySegment)
{
YAxis.transform.localScale = new Vector3(YAxis.transform.localScale.x, YLength + ySegment, YAxis.transform.localScale.z);
YpointCount = ((YLength - yStart) / ySegment) + 1;
for (int i = 0; i < YpointCount; i++)
{
float distance = 1;
Vector3 pos;
if (i == 0)
{
distance = yStart;
pos = transform.localPosition + new Vector3(0, distance, 0);
}
else
{
distance = ySegment;
pos = ListOfYPoints[i - 1].transform.localPosition + new Vector3(0, distance, 0);
}
GraphPoint temp = Instantiate(YPoint, transform.localPosition, transform.rotation);
temp.transform.parent = transform;
temp.transform.localPosition = pos;
temp.transform.localScale = temp.transform.localScale * graphScaleFactor;
temp.labelContainer.localPosition = new Vector3(XLength+ (1.8f*xOffset), 0, 0) / graphScaleFactor;
ListOfYPoints.Add(temp);
}
}
public void InitZAxis(int zMaxSize, float zStart, float zSegment, float zRowOffset, float xStart, float xSegment)
{
ZAxis.transform.localScale = new Vector3(ZAxis.transform.localScale.x, ZAxis.transform.localScale.y, ZLength + zSegment);
if (zSegment == 0)
{
ZpointCount = zMaxSize;
}
else
{
ZpointCount = ((ZLength - zStart) / zSegment) + 1;
}
for (int i = 0; i < ZpointCount; i++)
{
float distance = 1;
Vector3 pos;
if (i == 0)
{
distance = zStart;
pos = transform.localPosition + new Vector3(0, 0, -distance);
}
else
{
distance = zSegment;
pos = ListOfZPoints[i - 1].transform.localPosition + new Vector3(0, 0, -distance);
}
GraphPoint temp = Instantiate(ZPoint, transform.position, transform.rotation);
temp.transform.parent = transform;
temp.transform.localPosition = pos;
temp.transform.localScale = temp.transform.localScale * graphScaleFactor;
temp.labelContainer.localPosition = temp.labelContainer.localPosition = new Vector3(XLength + (1.8f * xOffset), 0, 0)/ graphScaleFactor;
ListOfZPoints.Add(temp);
GameObject grouptemp = GameObject.Instantiate(horizontalGroup, transform.position, transform.rotation);
grouptemp.transform.parent = barParent.transform;
grouptemp.transform.localPosition = pos + new Vector3((zRowOffset * i), 0, 0);
grouptemp.GetComponent<RectTransform>().sizeDelta = new Vector2(XLength, YLength);
grouptemp.GetComponent<HorizontalLayoutGroup>().padding.left = (int)xStart;
grouptemp.GetComponent<HorizontalLayoutGroup>().spacing = (int)xSegment;
grouptemp.transform.localScale = Vector3.one;
ListOfGroups.Add(grouptemp.GetComponent<BarGorup>());
// Debug.Log("count incremented =======" + ListOfGroups.Count);
}
}
public void AssignAxisName(int xIndex, int zIndex, string xValue, string zValue)
{
ListOfZPoints[zIndex].labelText = zValue;
ListOfXPoint[xIndex].labelText = xValue.ToString();
}
public void FetchYPointValues(int ymin, int ymax)
{
//Debug.Log("Final values min max " + ymin + " , " + ymax);
float range = ymax - ymin;
//Debug.Log("range & YpointCount" + range + " , " + YpointCount);
float offset = range / YpointCount;
//Debug.Log("offset " + offset);
float value = ymin;
for (int i = 0; i < ListOfYPoints.Count; i++)
{
value += offset;
ListOfYPoints[i].labelText = value.ToString();
//Debug.Log("value " + value);
}
}
public void FetchXPointValues(int xmin, int xmax)
{
//Debug.Log("Final values min max " + ymin + " , " + ymax);
float range = xmax - xmin;
//Debug.Log("range & YpointCount" + range + " , " + YpointCount);
float offset = range / XpointCount;
//Debug.Log("offset " + offset);
float value = xmin;
for (int i = 0; i < ListOfXPoint.Count; i++)
{
value += offset;
ListOfXPoint[i].labelText = value.ToString();
//Debug.Log("value " + value);
}
}
public void FetchZPointValues(int zmin, int zmax)
{
//Debug.Log("Final values min max " + ymin + " , " + ymax);
float range = zmax - zmin;
//Debug.Log("range & YpointCount" + range + " , " + YpointCount);
float offset = range / ZpointCount;
//Debug.Log("offset " + offset);
float value = zmin;
for (int i = 0; i < ListOfZPoints.Count; i++)
{
value += offset;
ListOfZPoints[i].labelText = value.ToString();
//Debug.Log("value " + value);
}
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 39766069005a5d5438ccd2046c6ce8f1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 200
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
namespace Graph.VittorCloud
{
public class GraphPoint : MonoBehaviour
{
#region publicVariable
public TextMeshPro label;
public Transform labelContainer;
public string labelText
{
get { return labelValue; }
set
{
labelValue = value;
label.text = labelValue;
}
}
#endregion
#region privateVariable
string labelValue;
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1a41ca301d4f6d848b996049761f0715
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d8efeae5d3905ea499191ae5c6f76b73
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,97 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;
using UnityEditor;
using UnityEngine;
namespace BarGraph.VittorCloud
{
#if UNITY_EDITOR
[CustomEditor(typeof(BarGraphGenerator))]
public class BarGraphGenerator_Editor : Editor
{
public override void OnInspectorGUI()
{
BarGraphGenerator script = (BarGraphGenerator)target;
//DrawDefaultInspector();
//OnHeaderGUI();
EditorGUILayout.Space();
EditorGUILayout.LabelField("Graph Settings", EditorStyles.boldLabel);
EditorGUILayout.Space();
script.MaxHeight = (int)EditorGUILayout.IntField("Max Height", script.MaxHeight = 10);
script.xStart = EditorGUILayout.FloatField("X Start", script.xStart);
script.yStart = EditorGUILayout.FloatField("Y Start", script.yStart);
script.zStart = EditorGUILayout.FloatField("Z Start", script.zStart);
script.segmentSizeOnXaxis = EditorGUILayout.FloatField("Segment Size On X axis", script.segmentSizeOnXaxis);
script.segmentSizeOnYaxis = EditorGUILayout.FloatField("Segment Size On Y axis", script.segmentSizeOnYaxis);
script.segmentSizeOnZaxis = EditorGUILayout.FloatField("Segment Size On Z axis", script.segmentSizeOnZaxis);
script.offsetBetweenXRow = EditorGUILayout.FloatField("Offset Between X Row", script.offsetBetweenXRow);
script.offsetBetweenZRow = EditorGUILayout.FloatField("Offset Between Z Row", script.offsetBetweenZRow);
EditorGUILayout.Space();
EditorGUILayout.LabelField("Graph Animation Settings", EditorStyles.boldLabel);
EditorGUILayout.Space();
script.animationSpeed = EditorGUILayout.Slider("Animation Speed", script.animationSpeed, 0f, 15f);
SerializedProperty graphAnimation = serializedObject.FindProperty(GetMemberName(() => script.graphAnimation));
EditorGUILayout.PropertyField(graphAnimation);
EditorGUILayout.Space();
EditorGUILayout.LabelField("Bar Settings", EditorStyles.boldLabel);
EditorGUILayout.Space();
SerializedProperty barPrefabe = serializedObject.FindProperty(GetMemberName(() => script.barPrefab));
EditorGUILayout.PropertyField(barPrefabe);
SerializedProperty barColorProperty = serializedObject.FindProperty(GetMemberName(() => script.barColorProperty));
EditorGUILayout.PropertyField(barColorProperty);
if (script.graphAnimation == BarGraphGenerator.AnimatioType.animationWithGradient)
script.barColorProperty = BarGraphGenerator.BarColor.HeightWiseGradient;
if (script.barColorProperty == BarGraphGenerator.BarColor.HeightWiseGradient)
{
SerializedProperty HeightWiseGredient = serializedObject.FindProperty(GetMemberName(() => script.HeightWiseGradient));
EditorGUILayout.PropertyField(HeightWiseGredient);
}
script.barScaleFactor = EditorGUILayout.FloatField("Bar Scale Factor", script.barScaleFactor);
SerializedProperty GraphRef = serializedObject.FindProperty(GetMemberName(() => script.GraphRef));
EditorGUILayout.PropertyField(GraphRef);
EditorGUILayout.Space();
EditorGUILayout.LabelField("Custom Events", EditorStyles.boldLabel);
EditorGUILayout.LabelField("The Following Events will pass the effected bar as a gameobject.", EditorStyles.helpBox);
SerializedProperty OnBarPointerDown = serializedObject.FindProperty(GetMemberName(() => script.OnBarPointerDown));
EditorGUILayout.PropertyField(OnBarPointerDown);
SerializedProperty OnBarPointerUp = serializedObject.FindProperty(GetMemberName(() => script.OnBarPointerUp));
EditorGUILayout.PropertyField(OnBarPointerUp);
SerializedProperty OnBarHoverEnter = serializedObject.FindProperty(GetMemberName(() => script.OnBarHoverEnter));
EditorGUILayout.PropertyField(OnBarHoverEnter);
SerializedProperty OnBarHoverExit = serializedObject.FindProperty(GetMemberName(() => script.OnBarHoverExit));
EditorGUILayout.PropertyField(OnBarHoverExit);
EditorGUILayout.Space();
EditorGUILayout.LabelField("This will be Invoked when the starting animation of the graph is completed.", EditorStyles.helpBox);
SerializedProperty OnInitialGraphCompleted = serializedObject.FindProperty(GetMemberName(() => script.OnInitialGraphCompleted));
EditorGUILayout.PropertyField(OnInitialGraphCompleted);
serializedObject.ApplyModifiedProperties();
}
public static string GetMemberName<T>(Expression<Func<T>> memberExpression)
{
MemberExpression expressionBody = (MemberExpression)memberExpression.Body;
return expressionBody.Member.Name;
}
}
#endif
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1ff13297263619d42baf381ad584c66d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace BarGraph.VittorCloud
{
public class CreateBarGraph : MonoBehaviour
{
[MenuItem("ViitorCloud/BarGraph/Create BarGraph")]
public static void CreatePieChart()
{
GameObject go = Instantiate(Resources.Load("BarGraph") as GameObject);
go.name = "BarGraph";
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 69244e4bde72ac94e9f6c74a2a5b813d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace Uitility.VittorCloud
{
public class Shortcut : Editor
{
[MenuItem("Tools/ActiveToggle _`")]
static void ToggleActivationSelection()
{
var go = Selection.activeGameObject;
go.SetActive(!go.activeSelf);
}
[MenuItem("Tools/Clear Console _]")] // CMD + SHIFT + C
static void ClearConsole()
{
// This simply does "LogEntries.Clear()" the long way:
var assembly = Assembly.GetAssembly(typeof(SceneView));
var type = assembly.GetType("UnityEditor.LogEntries");
var method = type.GetMethod("Clear");
method.Invoke(new object(), null);
//Debug.Log("Cleared");
}
[MenuItem("Tools/Clear PlayerFrebs _#]")] // CMD + SHIFT + C
static void ClearPlayerFrebs()
{
// This simply does "LogEntries.Clear()" the long way:
PlayerPrefs.DeleteAll();
//Debug.Log("PlayerFrebs Clear");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: afb5039e6539f7144ad2e06e33ebcc71
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a1aa5f886c5e91446997e3c77c0cebe8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,107 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Uitility.VittorCloud
{
public static class MathExtension
{
public static int Round(this int i, int range)
{
double roundNum = 0;
double nearest = 0;
nearest = Mathf.Pow(10, GetNumOfDigits(i) - 1);
if (i < 0)
nearest *= -1;
// Debug.Log("nearest of : " + i + " is : " + nearest);
if (i > nearest * 5 && range > 5 * nearest)
{
nearest = nearest * 10;
}
roundNum = Math.Round((double)i / nearest) * nearest;
// Debug.Log("roundNum of : " + i + " is : " + roundNum);
if (roundNum == i)
{
if (roundNum < 5 * nearest)
{
roundNum = 0;
}
else
{
roundNum = 5 * nearest;
}
}
//Debug.Log(" Final roundNum of : " + i + " is : " + roundNum);
return (int)roundNum;
}
public static int GetNumOfDigits(this Int32 n) =>
n == 0 ? 0 : 1 + (int)Math.Log10(Math.Abs(n));
public static float GetMaxValue(List<float> list)
{
float max = 0;
for (int i = 0; i < list.Count; i++)
{
if (i == 0)
{
max = list[i];
}
if (list[i] > max)
{
max = list[i];
}
}
// Debug.Log("max=" + max);
return max;
}
public static float GetMinValue(List<float> list)
{
float min = list[0];
for (int i = 0; i < list.Count; i++)
{
if (list[i] < min)
{
min = list[i];
}
}
// Debug.Log("Min=" + min);
return min;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 797c6219e13816b42a04a3b356a2cd22
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: