Compare commits

..

No commits in common. "dev_cyp" and "master" have entirely different histories.

9320 changed files with 542 additions and 2155153 deletions

40
.gitignore vendored
View File

@ -69,43 +69,3 @@ crashlytics-build.properties
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
Assets/Packages
Assets/Packages.meta
Assets/Shader2D-master
Assets/ZFBrowser
Assets/Resources/UI/Font/*.ttf
Assets/WorldPoliticalMapGlobeEdition
Assets/WorldPoliticalMapGlobeEdition.meta
Assets/earth
Assets/Chart And Graph
Assets/NuGet
Assets/NuGet.meta
Assets/earth.meta
Assets/MapWorkoutRecords.meta
Assets/Devices.txt
Assets/Devices.txt.meta
Assets/StreamingAssets.meta
Assets/Resources/Sound.meta
Assets/MapWorkoutRecords
Assets/Mapbox/User
Assets/Mapbox/User.meta
Packages/packages-lock.json
GPUCache
Assets/Shatalmic/plugin.unitypackage.meta
.idea
Assets/AVProVideo
Assets/StreamingAssets/AVProVideoSamples
Assets/StreamingAssets/AVProVideoSamples.meta
Assets/StreamingAssets
Assets/FacebookSDK
Assets/StreamingAssets
Assets/Models/MC_animations
Assets/Models/MC_max
Assets/FacebookSDK/SDK/Resources/FacebookSettings.asset
Assets/FacebookSDK/SDK/Resources/FacebookSettings.asset
Assets/AVProVideo.meta
Packages
Assets/Tree_Textures.meta
Packages
Assets/FacebookSDK/SDK/Resources.meta
Packages

View File

@ -1,6 +0,0 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}

View File

@ -1,130 +0,0 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
public class AndroidUpdate : PFUIPanel
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
JObject data { get; set; }
public void StartDownload(JObject jo)
{
transform.Find("Panel/CurrentVersion").GetComponent<Text>().text = $"{App.GetLocalString("Current Version:")} {App.AppVersion}";
transform.Find("Panel/LastestVersion").GetComponent<Text>().text = $"{App.GetLocalString("Latest Version:")} {jo.Value<string>("Version")}";
data = jo;
var path = Application.temporaryCachePath + "/PowerFun.apk";
StartCoroutine(DownLoadExe(data.Value<string>("Url"), path, (p, isComplete) =>
{
transform.Find("Panel/Size").GetComponent<Text>().text = $"{App.GetLocalString("Downloaded")} {Math.Round(p * 100, 0)}%";// string.Format(, a, b);
transform.Find("Panel/Progress").GetComponent<Image>().fillAmount = (float)p;
if (isComplete)
{
PlayerPrefs.SetString("exeVersion", data.Value<string>("Version"));
new FileInfo(path + ".pfdownload").MoveTo(path);
OpenApk(path);
//Application.Quit();
}
}));
}
/*下载文件*/
IEnumerator DownLoadExe(string url, string desFileName, Action<double, bool> OnDownloadProgressEvent)
{
string version = data.Value<string>("Version");
if (File.Exists(desFileName))
{
//if(PlayerPrefs.GetString("exeVersion")==)
if (version == null)
{
yield break;
}
else
{
if (version == PlayerPrefs.GetString("exeVersion"))
{
OpenApk(desFileName);
//Application.Quit();
yield break;
}
else
{
File.Delete(desFileName);
}
}
//File.Delete(desFileName);
}
if (File.Exists(desFileName + ".pfdownload"))
{
File.Delete(desFileName + ".pfdownload");
}
using (var uwr = UnityWebRequest.Get(url))
{
var operation = uwr.SendWebRequest();
while (!operation.isDone)
{
/*
* as BugFinder metnioned in the comments
* what you want to track is uwr.downloadProgress
*/
var downloadDataProgress = uwr.downloadProgress * 100;
/*
* use a float division here
* I don't know what type downloadDataProgress is
* but if it is an int than you will always get
* an int division <somethingSmallerThan100>/100 = 0
*/
//progressBar.fillAmount = downloadDataProgress / 100.0f;
OnDownloadProgressEvent.Invoke(uwr.downloadProgress, false);
Debug.Log("Download: " + downloadDataProgress);
yield return null;
}
ByteArrayToFile(desFileName + ".pfdownload", uwr.downloadHandler.data);
OnDownloadProgressEvent.Invoke(1, true);
}
}
bool ByteArrayToFile(string fileName, byte[] byteArray)
{
try
{
using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
{
fs.Write(byteArray, 0, byteArray.Length);
return true;
}
}
catch (Exception ex)
{
Debug.LogError(ex);
return false;
}
}
void OpenApk(string path)
{
#if !UNITY_EDITOR
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = jc.GetStatic<AndroidJavaObject>("currentActivity");
//Debug.Log("打开apk"+ "file://" + path);
activity.Call("OpenApk", path);
//Application.Quit();
#endif
}
}

View File

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

View File

@ -1,159 +0,0 @@
using Assets.Scripts;
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AppleInfoController : PFUIPanel
{
public Action afterClose = null;
private SignForm signForm;
private Dictionary<string, Selectable> signFormDict;
public bool startCaptcha = false;
protected override void Awake()
{
UIManager.AddEvent(transform.Find("FormContainer-Sign/btnClose").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
//if (afterClose != null)
//{
// afterClose.Invoke();
//}
});
signForm = new SignForm()
{
email = transform.Find("FormContainer-Sign/FirstPage/Email").GetComponent<InputField>(),
captcha = transform.Find("FormContainer-Sign/FirstPage/Captcha").GetComponent<InputField>(),
password = transform.Find("FormContainer-Sign/FirstPage/Password").GetComponent<InputField>(),
cpassword = transform.Find("FormContainer-Sign/FirstPage/CPassword").GetComponent<InputField>(),
};
signFormDict = new Dictionary<string, Selectable>
{
{ "Phone",signForm.email},
{ "Captcha",signForm.captcha},
{ "Pwd",signForm.password},
{ "CPwd",signForm.cpassword},
};
signPage1 = transform.Find("FormContainer-Sign/FirstPage");
UIManager.AddEvent(signPage1.Find("Captcha").Find("BtnGet").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
GetCaptcha();
});
UIManager.AddEvent(signPage1.Find("next").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Submit();
});
}
private async void Submit()
{
if (signForm.password.text != signForm.cpassword.text)
{
Utils.SetValidate(signFormDict, JArray.FromObject(new object[]
{
new { Field="Pwd"},
new { Field="CPwd"},
}));
Utils.showToast(gameObject, "Two password entries are inconsistent");//两次密码输入不一致
return;
}
var res = await ConfigHelper.userApi.AppleCompleteInfo(signForm.email.text, signForm.captcha.text, signForm.password.text);
if (res.result)
{
Utils.showToast(null, App.GetLocalString("Success"), type: 1);
App.CurrentUser.Phone = signForm.email.text;
if (afterClose != null)
{
afterClose.Invoke();
}
Close();
}
else
{
Utils.SetValidate(signFormDict, JArray.FromObject(res.data));
Utils.showToast(null, res.errMsg);
}
}
float timer = 1f;
int time = 60;
Transform signPage1;
async void GetCaptcha()
{
var btn = signPage1.Find("Captcha").Find("BtnGet");
btn.GetComponent<Button>().enabled = false;
btn.GetComponent<Button>().interactable = false;
var btnText = btn.Find("Text").GetComponent<Text>();
var Email = signForm.email;
var r = await ConfigHelper.userApi.GetCaptcha(Email.text);
//Timer t = new Ti
if (r.result)
{
//if (r.data.Value<bool>("isExist"))
//{
// signPage1.Find("Password").gameObject.SetActive(false);
// signPage1.Find("CPassword").gameObject.SetActive(false);
//}
//else
//{
// signPage1.Find("Password").gameObject.SetActive(true);
// signPage1.Find("CPassword").gameObject.SetActive(true);
//}
time = 60;
btnText.text = $"Again({time})";
btn.GetComponent<Button>().enabled = false;
btn.GetComponent<Button>().interactable = false;
startCaptcha = true;
//timer.Interval = 1000;
//timer.AutoReset = true;
//timer.Elapsed += new ElapsedEventHandler(CaptchaTimerTick);
//timer.Enabled = true;
//btnGet.
}
else
{
btn.GetComponent<Button>().enabled = true;
btn.GetComponent<Button>().interactable = true;
Utils.showToast(gameObject, r.errMsg);
Utils.SetValidate(signFormDict, r.errFieldMsg);
}
}
void CaptchaTimerTick()
{
timer -= Time.deltaTime;
if (timer <= 0)
{
var btn = signPage1.Find("Captcha").Find("BtnGet");
var btnText = signPage1.Find("Captcha").Find("BtnGet").Find("Text").GetComponent<Text>();
btnText.text = $"{App.GetLocalString("Again")}({time--})";
if (time < 0)
{
btnText.text = App.GetLocalString("Get");
btn.GetComponent<Button>().enabled = true;
btn.GetComponent<Button>().interactable = true;
startCaptcha = false;
//timer.Stop();
}
timer += 1.0f;
}
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (startCaptcha)
{
CaptchaTimerTick();
}
}
}

View File

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

View File

@ -1,282 +0,0 @@
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
public class BannerController : MonoBehaviour
{
// Start is called before the first frame update
private List<CanvasGroup> itemList;
private List<Vector3> standardPositions;
private List<Recommand> list;
private int currentIndex = 1;
private Dictionary<string, Texture> caches;
void Awake()
{
itemList = new List<CanvasGroup>
{
transform.Find("1").GetComponent<CanvasGroup>(),
transform.Find("2").GetComponent<CanvasGroup>(),
transform.Find("3").GetComponent<CanvasGroup>()
};
caches = new Dictionary<string, Texture>();
standardPositions = new List<Vector3>
{
transform.Find("1").localPosition,transform.Find("2").localPosition,transform.Find("3").localPosition
};
AddTouchEvent();
Debug.Log(standardPositions[0]);
Debug.Log(standardPositions[1]);
Debug.Log(standardPositions[2]);
}
TKPanRecognizer pan;
private void AddTouchEvent()
{
pan = new TKPanRecognizer();
var panList = new List<CanvasGroup>();
pan.gestureRecognizedEvent += (r) =>
{
if (!App.currentPageIsHome) return;
int center = GetCenterIndex(),
left = GetSideIndex(true),
right = GetSideIndex(false);
if (!(center == -1 || left == -1 || right == -1) && panList.Count == 0)
{
panList.Add(itemList[left]);
panList.Add(itemList[center]);
panList.Add(itemList[right]);
}
if (panList.Count == 0) return;
var startPoint = r.startTouchLocation();
if (((RectTransform)transform).isPointInTransfrom(startPoint))
{
foreach (var item in panList)
{
item.GetComponent<Button>().onClick.RemoveAllListeners();
}
var offset = pan.deltaTranslation;
if (panList[1].transform.localPosition.x == 0)
{
panList[1].transform.DOScale(0.8f, 0.5f);
}
if (offset.x > 0)
{
//-43 0 43
//后面的 如果往左,需要回到-43再往右
panList[0].transform.localPosition += new Vector3(1, 0, 0);
panList[1].transform.localPosition += new Vector3(1, 0, 0);
panList[2].transform.localPosition += new Vector3(-1, 0, 0);
}
else if (offset.x < 0)
{
panList[0].transform.localPosition += new Vector3(1, 0, 0);
panList[1].transform.localPosition += new Vector3(-1, 0, 0);
//后面的 如果往右需要回到43再往左
panList[2].transform.localPosition += new Vector3(-1, 0, 0);
}
}
else
{
panList.Clear();
}
};
pan.gestureCompleteEvent += (r) =>
{
if (!App.currentPageIsHome) return;
if (panList.Count == 0) return;
if (panList[1].transform.localPosition.x < 0)
{
DOLeft(panList[0], panList[1], panList[2]);
}
else
{
DORight(panList[0], panList[1], panList[2]);
}
panList.Clear();
};
TouchKit.addGestureRecognizer(pan);
}
int sIndex = 0, eIndex = 2;
private void Start()
{
GetList();
}
async void GetList()
{
var res = await ConfigHelper.mapApi.GetRecommendList();
if (res.result)
{
if (res.data.Count >= 3)
{
sIndex = 0;eIndex = 2;
Initial(res.data);
gameObject.SetActive(true);
}
else
{
gameObject.SetActive(false);
}
}
}
public void Initial(List<Recommand> list)
{
int index = 0;
foreach (CanvasGroup c in itemList)
{
var area = list[index++];
c.GetComponent<RecommendController>().Initial(area, caches);
c.GetComponent<Button>().onClick.RemoveAllListeners();
if (c.alpha != 1)
{
if (c.transform.localPosition.x < 0)
{
c.GetComponent<Button>().onClick.AddListener(Right);
}
else
{
c.GetComponent<Button>().onClick.AddListener(Left);
}
}
else
{
c.GetComponent<Button>().onClick.AddListener(()=>GoDetail(c));
}
}
this.list = list;
}
bool animateLock = false;
private void Right()
{
int center = GetCenterIndex(),
left = GetSideIndex(true),
right = GetSideIndex(false);
if (center == -1 || left == -1 || right == -1 || animateLock) return;
animateLock = true;
if (leftse != null) leftse.Complete(true);
DORight(itemList[left], itemList[center], itemList[right]);
}
void DORight(CanvasGroup left, CanvasGroup center, CanvasGroup right)
{
Sequence se = DOTween.Sequence();
se.Join(center.DOFade(0.5f, 0.3f));
se.Join(center.GetComponent<RectTransform>().DOScale(Vector3.one * 0.8f, 0.3f));
se.Join(center.GetComponent<RectTransform>().DOLocalMoveX(offset, 0.3f));
se.Join(right.GetComponent<RectTransform>().DOLocalMoveX(-1* offset, 0.3f));
var area = list[((sIndex - 1) + list.Count) % list.Count];
sIndex--;
eIndex--;
if (sIndex < 0) sIndex = (sIndex + list.Count) % list.Count;
if (eIndex < 0) eIndex = (eIndex + list.Count) % list.Count;
Debug.Log($"{sIndex},{eIndex}");
right.GetComponent<RecommendController>().Initial(area, caches);
se.Join(left.DOFade(1, 0.3f));
se.Join(left.GetComponent<RectTransform>().DOScale(Vector3.one, 0.3f));
se.Join(left.GetComponent<RectTransform>().DOLocalMoveX(0, 0.3f));
se.Play().onComplete = ()=> { animateLock = false; };
rightse = se;
left.transform.SetAsLastSibling();
//事件改变
left.GetComponent<Button>().onClick.RemoveAllListeners();
left.GetComponent<Button>().onClick.AddListener(() => GoDetail(left));
center.GetComponent<Button>().onClick.RemoveAllListeners();
center.GetComponent<Button>().onClick.AddListener(Left);
right.GetComponent<Button>().onClick.RemoveAllListeners();
right.GetComponent<Button>().onClick.AddListener(Right);
}
#if UNITY_STANDALONE_WIN
float offset = 110;
#else
float offset = 43;
#endif
Sequence leftse, rightse;
private void Left()
{
int center = GetCenterIndex(),
left = GetSideIndex(true),
right = GetSideIndex(false);
if (center == -1 || left == -1 || right == -1|| animateLock) return;
animateLock = true;
if (rightse != null) rightse.Complete(true);
DOLeft(itemList[left], itemList[center], itemList[right]);
}
void DOLeft(CanvasGroup left, CanvasGroup center, CanvasGroup right)
{
Sequence se = DOTween.Sequence();
se.Join(center.DOFade(0.5f, 0.3f));
se.Join(center.GetComponent<RectTransform>().DOScale(Vector3.one * 0.8f, 0.3f));
se.Join(center.GetComponent<RectTransform>().DOLocalMoveX(-1* offset, 0.3f));
se.Join(left.GetComponent<RectTransform>().DOLocalMoveX(offset, 0.3f));
var area = list[((eIndex + 1) + list.Count) % list.Count];
sIndex++;
eIndex++;
if (sIndex >= list.Count - 1) sIndex = sIndex % list.Count;
if (eIndex >= list.Count - 1) eIndex = eIndex % list.Count;
Debug.Log($"{sIndex},{eIndex}");
var centerArea = list[currentIndex + 1];
left.GetComponent<RecommendController>().Initial(area, caches);
if (currentIndex < 0) currentIndex = list.Count - 1;
se.Join(right.DOFade(1, 0.3f));
se.Join(right.GetComponent<RectTransform>().DOScale(Vector3.one, 0.3f));
se.Join(right.GetComponent<RectTransform>().DOLocalMoveX(0, 0.3f));
se.Play().onComplete = () => { animateLock = false; };
leftse = se;
right.transform.SetAsLastSibling();
//事件改变
right.GetComponent<Button>().onClick.RemoveAllListeners();
right.GetComponent<Button>().onClick.AddListener(() => GoDetail(right));
center.GetComponent<Button>().onClick.RemoveAllListeners();
center.GetComponent<Button>().onClick.AddListener(Right);
left.GetComponent<Button>().onClick.RemoveAllListeners();
left.GetComponent<Button>().onClick.AddListener(Left);
}
int GetCenterIndex()
{
return itemList.FindIndex(x => x.transform.localPosition.x == 0);
}
int GetSideIndex(bool left)
{
return itemList.FindIndex(x => left ? x.transform.localPosition.x < 0 : x.transform.localPosition.x > 0);
}
void GoDetail(CanvasGroup c)
{
if (c.transform.localPosition.x == 0)
{
var se = DOTween.Sequence();
se.Append(c.transform.DOScale(1.05f * Vector3.one, 0.15f));
se.Append(c.transform.DOScale(1f * Vector3.one, 0.15f));
se.Play().onComplete = ()=>
{
c.GetComponent<RecommendController>().DoWithType();
};
}
}
float autoTime = 5;
// Update is called once per frame
void Update()
{
autoTime -= Time.deltaTime;
if (autoTime < 0)
{
Left();
autoTime += 5;
}
}
private void OnDestroy()
{
Debug.Log(248+"毁灭");
TouchKit.removeGestureRecognizer(pan);
caches = null;
Resources.UnloadUnusedAssets();
GC.Collect();
}
}

View File

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

View File

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

View File

@ -1,19 +0,0 @@
The following 3rd parties are integrated into Graph and Chart:
In the folder Chart And Graph/Themes/Common/Fonts :
Each font has it's own folder with full license detials
Exo2 - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/exo-2
ABeeZee - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/abeezee
Comprehension - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/comprehension
Enriqueta - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/enriqueta
Fengardo-neue - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/fengardo-neue
Overpass - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/overpass
Rambla - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/rambla
Scada - SIL OPEN FONT LICENSE - https://www.fontsquirrel.com/license/scada
SimpleJson in the folder Chart And Graph/SimpleJSON-master:
Licensed under MIT license :https://github.com/Bunny83/SimpleJSON/blob/master/LICENSE

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: b593c70250d4fb94bb76f653a500cd6d
timeCreated: 1536774863
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: c3cc22ffba1b29a44b56007d189a1750
folderAsset: yes
timeCreated: 1536396364
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,26 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ChartAndGraph
{
public abstract class ChartParser
{
public abstract bool SetPathRelativeTo(string pathObject);
/// <summary>
/// returns null if object not found
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public abstract object GetObject(string name);
public abstract object GetChildObject(object obj, string name);
public abstract IEnumerable<KeyValuePair<string , object>> GetAllChildObjects(object obj);
public abstract string GetChildObjectValue(object obj, string name);
public abstract string GetItem(object arr, int item);
public abstract object GetItemObject(object arr, int item);
public abstract int GetArraySize(object arr);
public abstract string ObjectValue(object obj);
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 5948d4ad51f370c4f927d0d10573cc84
timeCreated: 1536396364
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,134 +0,0 @@
#define Graph_And_Chart_PRO
using SimpleJSON;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace ChartAndGraph
{
class JsonParser : ChartParser
{
JSONNode mBaseJson;
JSONNode mRelativePath;
public JsonParser(string data)
{
mBaseJson = JSON.Parse(data);
mRelativePath = mBaseJson;
}
object GetObjectFromRoot(JSONNode root, string name)
{
string[] parents = name.Split('>');
object current = root;
for (int i = 0; current != null && i < parents.Length; i++)
{
string nextNode = parents[i];
current = GetChildObject(current, nextNode);
}
return current;
}
public override int GetArraySize(object arr)
{
var node = (JSONNode)arr;
if (node.IsArray == false)
return 0;
return node.Count;
}
public override object GetChildObject(object obj, string name)
{
var node = (JSONNode)obj;
if (name.Length <= 0)
return obj;
if (char.IsDigit(name[0])) // if it is a number then find by order , atag name cannot start with a digit
{
if (node.IsArray == false)
return null;
int index = 0;
if (int.TryParse(name, out index) == false) // try parsing the number
return null;
if (index < 0 || index >= node.Count)
return null;
return node[index];
}
if(name.Length>=2 && name[0] == '"' && name[name.Length-1] == '"')
{
name = name.Substring(1, name.Length - 2); //strip quatation marks
}
return node[name];
}
public override bool SetPathRelativeTo(string pathObject)
{
mRelativePath = (JSONNode)GetObjectFromRoot(mBaseJson, pathObject);
if (mRelativePath == null)
{
mRelativePath = mBaseJson;
return false;
}
return true;
}
public override object GetObject(string name)
{
return GetObjectFromRoot(mRelativePath, name);
}
public override string GetItem(object arr, int item)
{
var element = arr as JSONNode;
if (element == null)
return null;
var child = element[item] as JSONNode;
if (child == null)
return null;
return ObjectValue(child);
}
public override object GetItemObject(object arr, int item)
{
var element = arr as JSONNode;
if (element == null)
return null;
var child = element[item];
return child;
}
public override string ObjectValue(object obj)
{
var element = obj as JSONNode;
return element.Value;
}
public override string GetChildObjectValue(object obj, string name)
{
var element = obj as JSONNode;
if (element == null)
return null;
try
{
var child = element[name] as JSONNode;
return ObjectValue(child);
}
catch(Exception)
{
}
return null;
}
public override IEnumerable<KeyValuePair<string, object>> GetAllChildObjects(object obj)
{
var node = (JSONNode)obj;
if (node.IsObject == false)
yield break;
foreach(var key in node.Keys)
yield return new KeyValuePair<string, object>(key, node[key]);
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 0693b788053aab64a88908e1e3d6b944
timeCreated: 1536396364
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,146 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
#if WINDOWS_UWP
using Windows.Data.Xml.Dom;
#else
using System.Xml;
#endif
namespace ChartAndGraph
{
class XMLParser : ChartParser
{
XmlDocument mXmlDoc;
XmlElement mRelativeElement;
public XMLParser(string xml)
{
mXmlDoc = new XmlDocument();
#if WINDOWS_UWP
mXmlDoc.LoadXml(xml);
#else
using (var reader = new StringReader(xml))
{
mXmlDoc.Load(reader);
}
#endif
mRelativeElement = mXmlDoc.DocumentElement;
}
public override int GetArraySize(object arr)
{
var element = arr as XmlElement;
if (element == null)
return 0;
return element.ChildNodes.Count;
}
public override object GetChildObject(object obj, string name)
{
var node = (XmlElement)obj;
if (name.Length <= 0)
return obj;
if (char.IsDigit(name[0])) // if it is a number then find by order , atag name cannot start with a digit
{
int index = 0;
if (int.TryParse(name, out index) == false) // try parsing the number
return null;
if (index < 0 || index >= node.ChildNodes.Count)
return null;
return node.ChildNodes[index];
}
return node.SelectSingleNode(name);
}
public override object GetItemObject(object arr, int item)
{
var element = arr as XmlElement;
if (element == null)
return null;
var child = element.ChildNodes[item] as XmlElement;
return child;
}
object GetObjectFromRoot(XmlElement root, string name)
{
string[] parents = name.Split('>');
object current = root;
for (int i = 0; current != null && i < parents.Length; i++)
{
string nextNode = parents[i];
current = GetChildObject(current, nextNode);
}
return current;
}
public override object GetObject(string name)
{
return GetObjectFromRoot(mRelativeElement, name);
}
public override bool SetPathRelativeTo(string pathObject)
{
mRelativeElement = (XmlElement)GetObjectFromRoot(mXmlDoc.DocumentElement, pathObject);
if (mRelativeElement == null)
{
mRelativeElement = mXmlDoc.DocumentElement;
return false;
}
return true;
}
public override string GetChildObjectValue(object obj, string name)
{
var element = obj as XmlElement;
if (element == null)
return null;
var child = element.SelectSingleNode(name) as XmlElement;
if (child == null)
return null;
return ObjectValue(child);
}
public override string GetItem(object arr, int item)
{
var element = arr as XmlElement;
if (element == null)
return null;
var child = element.ChildNodes[item] as XmlElement;
if (child == null)
return null;
return ObjectValue(child);
}
public override string ObjectValue(object obj)
{
var element = obj as XmlElement;
if (element == null)
return null;
return element.InnerText;
}
public override IEnumerable<KeyValuePair<string, object>> GetAllChildObjects(object obj)
{
var element = obj as XmlElement;
if (element == null)
yield break;
foreach(var node in element.ChildNodes)
{
var xml = node as XmlElement;
if(xml != null)
{
#if WINDOWS_UWP
yield return new KeyValuePair<string, object>(xml.TagName, xml);
#else
yield return new KeyValuePair<string, object>(xml.Name, xml);
#endif
}
}
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 878b8742852947849810df5d673d597c
timeCreated: 1536396365
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: bf8f979c9af34ff43ab739a7cf401b92
folderAsset: yes
timeCreated: 1560597265
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,32 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace ChartAndGraph
{
[CustomPropertyDrawer(typeof(AutoFloat))]
class AutoFloatInspector : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
label = EditorGUI.BeginProperty(position, label, property);
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
SerializedProperty auto = property.FindPropertyRelative("Automatic");
SerializedProperty val = property.FindPropertyRelative("Value");
int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
bool res = EditorGUI.ToggleLeft(position,"Auto",auto.boolValue);
EditorGUI.indentLevel = indent;
EditorGUI.indentLevel++;
if (auto.boolValue == false && EditorGUI.showMixedValue == false)
val.floatValue = EditorGUILayout.FloatField("Value",val.floatValue);
auto.boolValue = res;
EditorGUI.indentLevel--;
EditorGUI.EndProperty();
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: c989bbf118ca01e4aab213559170875f
timeCreated: 1479209594
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,273 +0,0 @@
#define Graph_And_Chart_PRO
using ChartAndGraph;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace ChartAndGraph
{
[CustomEditor(typeof(AxisBase), true)]
class AxisInspector : Editor
{
bool mMain = false;
bool mSub = false;
public override void OnInspectorGUI()
{
AxisBase axis = (AxisBase)target;
if (axis.gameObject == null)
return;
AnyChart chart = axis.gameObject.GetComponent<AnyChart>();
if (chart == null)
return;
if((chart is AxisChart) == false)
{
EditorGUILayout.LabelField(string.Format("Chart of type {0} does not support axis",chart.GetType().Name));
return;
}
SerializedProperty simpleViewProp = serializedObject.FindProperty("SimpleView");
if (simpleViewProp == null)
return;
Type canvasType = (chart is ICanvas) ? typeof(CanvasAttribute) : typeof(NonCanvasAttribute);
EditorGUILayout.BeginVertical();
bool negate = false;
if (simpleViewProp.boolValue == true)
negate = GUILayout.Button("Advanced View");
else
negate = GUILayout.Button("Simple View");
if (negate)
simpleViewProp.boolValue = !simpleViewProp.boolValue;
bool simple = simpleViewProp.boolValue;
SerializedProperty depth = serializedObject.FindProperty("depth");
if (depth != null)
EditorGUILayout.PropertyField(depth);
SerializedProperty format= serializedObject.FindProperty("format");
EditorGUILayout.PropertyField(format);
if (simple)
DoSimpleView(canvasType);
else
DoAdvanvedView(canvasType,true);
EditorGUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
serializedObject.Update();
}
void SetValue(SerializedProperty assignTo,SerializedProperty from)
{
if(assignTo.propertyType != from.propertyType)
{
Debug.LogWarning("type does not match");
return;
}
if (assignTo.type == "AutoFloat")
{
SerializedProperty auto = assignTo.FindPropertyRelative("Automatic");
SerializedProperty val = assignTo.FindPropertyRelative("Value");
SerializedProperty autofrom = from.FindPropertyRelative("Automatic");
SerializedProperty valfrom = from.FindPropertyRelative("Value");
auto.boolValue = autofrom.boolValue;
val.floatValue = valfrom.floatValue;
return;
}
switch (assignTo.propertyType)
{
case SerializedPropertyType.Float:
assignTo.floatValue = from.floatValue;
break;
case SerializedPropertyType.Integer:
assignTo.intValue = from.intValue;
break;
case SerializedPropertyType.Enum:
assignTo.enumValueIndex = from.enumValueIndex;
break;
case SerializedPropertyType.Boolean:
assignTo.boolValue = from.boolValue;
break;
case SerializedPropertyType.String:
assignTo.stringValue = from.stringValue;
break;
case SerializedPropertyType.ObjectReference:
assignTo.objectReferenceValue = from.objectReferenceValue;
break;
default:
Debug.LogWarning("type cannot be set");
break;
}
}
Type getTypeFromField(Type type,string fieldName)
{
FieldInfo inf = type.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
if (inf == null)
return null;
return inf.FieldType;
}
bool CompareValues(Type type,string fieldName,object a,object b)
{
FieldInfo inf= type.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
object valA = inf.GetValue(a);
object valB = inf.GetValue(b);
if(valA is UnityEngine.Object && valB is UnityEngine.Object)
{
if(((UnityEngine.Object)valA) == ((UnityEngine.Object)valB))
return true;
return false;
}
if (valA == null && valB == null)
return true;
return valA.Equals(valB);
}
void DoSimpleView(Type canvasType)
{
SerializedProperty it = serializedObject.FindProperty("mainDivisions");
SerializedProperty SubDivisions = serializedObject.FindProperty("subDivisions");
object mainDivision = ((AxisBase)target).MainDivisions;
object subDivision = ((AxisBase)target).SubDivisions;
if (it == null || SubDivisions == null)
return;
SerializedProperty end = it.GetEndProperty();
while(it.NextVisible(true) && SerializedProperty.EqualContents(end,it) == false)
{
if (it.name == "SimpleView")
continue;
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), it.name, canvasType) == false)
if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), it.name, canvasType) == false)
continue;
if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), it.name, typeof(SimpleAttribute)) == false)
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), it.name, typeof(SimpleAttribute)) == false)
continue;
SerializedProperty clone = SubDivisions.FindPropertyRelative(it.name);
if (clone == null)
Debug.LogWarning("can't find property " + it.name);
bool equal = CompareValues(typeof(ChartDivisionInfo), clone.name, mainDivision, subDivision);
Type t = getTypeFromField(typeof(ChartDivisionInfo), clone.name);
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = !equal;
DoMixedFiled(it, t);
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
SetValue(clone, it);
}
DoAdvanvedView(canvasType,false);
}
public void DoMixedFiled(SerializedProperty prop,Type type)
{
if(prop.type == "AutoFloat")
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(prop.displayName);
SerializedProperty auto = prop.FindPropertyRelative("Automatic");
SerializedProperty val = prop.FindPropertyRelative("Value");
auto.boolValue = EditorGUILayout.ToggleLeft("Auto", auto.boolValue);
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel++;
if (auto.boolValue == false && EditorGUI.showMixedValue == false)
val.floatValue = EditorGUILayout.FloatField("Value",val.floatValue);
EditorGUI.indentLevel--;
return;
}
switch(prop.propertyType)
{
case SerializedPropertyType.Float:
if(prop.name == "FontSharpness")
prop.floatValue = EditorGUILayout.Slider(prop.displayName, prop.floatValue,1f,3f);
else
prop.floatValue = EditorGUILayout.FloatField(prop.displayName,prop.floatValue);
break;
case SerializedPropertyType.Integer:
if (prop.name == "FractionDigits")
prop.intValue = EditorGUILayout.IntSlider(prop.displayName, prop.intValue,0,7);
else
prop.intValue = EditorGUILayout.IntField(prop.displayName, prop.intValue);
break;
case SerializedPropertyType.Enum:
ChartDivisionAligment selected = (ChartDivisionAligment)Enum.Parse( typeof(ChartDivisionAligment), prop.enumNames[prop.enumValueIndex]);
Enum res = EditorGUILayout.EnumPopup(prop.displayName, selected);
string newName= Enum.GetName(typeof(ChartDivisionAligment), res);
for (int i = 0; i < prop.enumNames.Length; ++i)
{
if (prop.enumNames[i] == newName)
{
prop.enumValueIndex = i;
break;
}
}
break;
case SerializedPropertyType.String:
prop.stringValue = EditorGUILayout.TextField(prop.displayName, prop.stringValue);
break;
case SerializedPropertyType.Boolean:
prop.boolValue = EditorGUILayout.Toggle(prop.displayName, prop.boolValue);
break;
case SerializedPropertyType.ObjectReference:
if(type != null)
prop.objectReferenceValue = EditorGUILayout.ObjectField(prop.displayName, prop.objectReferenceValue, type, true);
break;
default:
Debug.LogWarning("type cannot be set");
break;
}
}
void DoAdvanvedView(Type canvasType,bool includeSimple)
{
SerializedProperty mainDivisions = serializedObject.FindProperty("mainDivisions");
SerializedProperty subDivisions = serializedObject.FindProperty("subDivisions");
mMain =mainDivisions.isExpanded = EditorGUILayout.Foldout(mainDivisions.isExpanded, "Main Divisions");
if (mMain)
{
EditorGUI.indentLevel++;
SerializedProperty end = mainDivisions.GetEndProperty();
while (mainDivisions.NextVisible(true) && SerializedProperty.EqualContents(mainDivisions, end) == false)
{
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), mainDivisions.name, canvasType) == false)
if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), mainDivisions.name, canvasType) == false)
continue;
if (includeSimple == false)
{
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), mainDivisions.name, typeof(SimpleAttribute)))
continue;
}
EditorGUILayout.PropertyField(mainDivisions);
}
EditorGUI.indentLevel--;
}
mSub = subDivisions.isExpanded = EditorGUILayout.Foldout(subDivisions.isExpanded, "Sub Divisions");
if (mSub)
{
EditorGUI.indentLevel++;
SerializedProperty end = subDivisions.GetEndProperty();
while (subDivisions.NextVisible(true) && SerializedProperty.EqualContents(subDivisions, end) == false)
{
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), subDivisions.name, canvasType) == false)
if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), subDivisions.name, canvasType) == false)
continue;
if (includeSimple == false)
{
if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), subDivisions.name, typeof(SimpleAttribute)))
continue;
}
EditorGUILayout.PropertyField(subDivisions);
}
EditorGUI.indentLevel--;
}
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 898567b381452e94794158c16012f617
timeCreated: 1479124371
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,364 +0,0 @@
#define Graph_And_Chart_PRO
using ChartAndGraph;
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(BarChart),true)]
class BarChartInspetor : Editor
{
bool mCategories = false;
bool mGroups = false;
string mCategoryError = null;
string mNewCategoryName = "";
string mNewGroupName = "";
string mGroupError = null;
GUIStyle mRedStyle;
GUIStyle mBold;
HashSet<string> mAllNames = new HashSet<string>();
GUIStyle mSplitter;
List<int> mToRemove = new List<int>();
List<int> mToUp = new List<int>();
Dictionary<string, string> mOperations = new Dictionary<string, string>();
ChartDataEditor mWindow;
bool mUpdateWindow = false;
Texture mSettings;
GUIContent MaxBarValue = new GUIContent("Max Bar Value :", "All the bars are scaled according to this value, Bars that are larger then this value are clamped");
GUIContent MinBarValue = new GUIContent("Min Bar Value :", "All the bars are scaled according to this value, Bars that are lower then this value are clamped");
RenameWindow mRenameWindow;
public void OnEnable()
{
mRedStyle = new GUIStyle();
mRedStyle.normal.textColor = Color.red;
mSplitter = new GUIStyle();
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
mSplitter.stretchWidth = true;
mSplitter.margin = new RectOffset(0, 0, 7, 7);
}
public void Splitter()
{
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
if (Event.current.type == EventType.Repaint)
{
Color restoreColor = GUI.color;
GUI.color = new Color(0.5f, 0.5f, 0.5f);
mSplitter.Draw(position, false, false, false, false);
GUI.color = restoreColor;
}
}
private void DoOperations(SerializedProperty items,int size,string type)
{
mToRemove.Clear();
mToUp.Clear();
bool up = false;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
string arg = type + "|" + name;
string res = null;
if (up == true)
{
mToUp.Add(i);
up = false;
}
if (mOperations.TryGetValue(arg, out res))
{
if (res == "remove")
mToRemove.Add(i);
if (res == "up" && i > 0)
mToUp.Add(i);
if (res == "down")
up = true;
mOperations.Remove(arg);
}
}
for (int i = 0; i < mToRemove.Count; i++)
items.DeleteArrayElementAtIndex(mToRemove[i]);
for (int i = 0; i < mToUp.Count; i++)
{
int cur = mToUp[i];
items.MoveArrayElement(cur, cur - 1);
}
}
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
{
SerializedProperty items = data.FindPropertyRelative(property);
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
//bool up, down;
mAllNames.Clear();
int size = items.arraySize;
if (Event.current.type == EventType.Layout)
DoOperations(items, size, type);
size = items.arraySize;
if (items.isExpanded)
{
EditorGUI.indentLevel++;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
mAllNames.Add(name);
EditorGUILayout.BeginHorizontal();
bool toogle = false;
if (nameProp != null)
toogle = entry.isExpanded = EditorGUILayout.Foldout(entry.isExpanded, name);
else
{
toogle = false;
EditorGUILayout.LabelField(name);
}
GUILayout.FlexibleSpace();
if(GUILayout.Button("..."))
DoContext(type, name);
EditorGUILayout.EndHorizontal();
if (toogle)
{
EditorGUI.indentLevel++;
if (nameProp != null)
{
SerializedProperty end = entry.GetEndProperty(true);
entry.Next(true);
if (SerializedProperty.EqualContents(entry, end) == false)
{
do
{
if (entry.name != "Name")
EditorGUILayout.PropertyField(entry, true);
}
while (entry.Next(entry.name == "Materials") && SerializedProperty.EqualContents(entry, end) == false);
}
}
EditorGUI.indentLevel--;
}
}
if (errorMessage != null)
EditorGUILayout.LabelField(errorMessage, mRedStyle);
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
EditorGUILayout.BeginHorizontal();
newName = EditorGUILayout.TextField(newName);
//GUILayout.Space(indentAdd.xMin);
if (GUILayout.Button("Add"))
{
bool error = false;
if (newName.Trim().Length == 0)
{
errorMessage = "Name can't be empty";
error = true;
}
else if (ChartEditorCommon.IsAlphaNum(newName) == false)
{
errorMessage = "Name conatins invalid characters";
error = true;
}
else if (mAllNames.Contains(newName))
{
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
error = true;
}
if (error == false)
{
errorMessage = null;
items.InsertArrayElementAtIndex(size);
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
if (newItemName == null)
newItem.stringValue = newName;
else
newItemName.stringValue = newName;
newName = "";
UpdateWindow();
}
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
else
{
errorMessage = null;
}
UpdateWindow();
}
void callback(object val)
{
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
mOperations[pair.Key] = pair.Value;
}
bool RenameGroup(string fromName, string toName)
{
BarChart barChart = (BarChart)serializedObject.targetObject;
try
{
barChart.DataSource.RenameGroup(fromName, toName);
}
catch (Exception)
{
return false;
}
serializedObject.Update();
if (barChart.gameObject.activeInHierarchy)
barChart.GenerateChart();
else
EditorUtility.SetDirty(barChart);
return true;
}
bool RenameCategory(string fromName,string toName)
{
BarChart barChart = (BarChart)serializedObject.targetObject;
try
{
barChart.DataSource.RenameCategory(fromName, toName);
}
catch(Exception)
{
return false;
}
serializedObject.Update();
if(barChart.gameObject.activeInHierarchy)
barChart.GenerateChart();
else
EditorUtility.SetDirty(barChart);
return true;
}
void RenameCalled(object val)
{
var data = (KeyValuePair<string, string>)val;
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
mRenameWindow = window;
if(data.Key == "category")
window.ShowDialog(data.Value, data.Key, RenameCategory);
else if(data.Key == "group")
window.ShowDialog(data.Value, data.Key, RenameGroup);
}
void DoContext(string type,string name)
{
string arg = type + "|" + name;
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Move Up"), false,callback, new KeyValuePair<string, string>(arg, "up"));
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
menu.ShowAsContext();
}
void UpdateWindow()
{
mUpdateWindow = true;
}
void OnDisable()
{
if(mRenameWindow != null)
{
mRenameWindow.Close();
mRenameWindow = null;
}
if (mWindow != null)
{
mWindow.Close();
mWindow = null;
}
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.Update();
SerializedProperty barData = serializedObject.FindProperty("Data");
EditorGUILayout.BeginVertical();
Splitter();
if(mBold == null)
{
mBold = new GUIStyle(EditorStyles.foldout);
//mBold.fontStyle = FontStyle.Bold;
}
// EditorStyles.foldout.fontStyle = FontStyle.Bold;
// fold = EditorGUILayout.Foldout(fold,"Bar Data", EditorStyles.foldout);
//EditorStyles.foldout.fontStyle = FontStyle.Normal;
// if (fold)
// {
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
NamedItemEditor(barData, "category", "mCategories", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
NamedItemEditor(barData, "group", "mGroups", "Groups", ref mGroupError, ref mGroups, ref mNewGroupName);
SerializedProperty maxProp = barData.FindPropertyRelative("maxValue");
SerializedProperty minProp = barData.FindPropertyRelative("minValue");
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(MinBarValue, EditorStyles.boldLabel);
SerializedProperty automaticProp = barData.FindPropertyRelative("automaticMinValue");
bool automatic = automaticProp.boolValue;
automatic = GUILayout.Toggle(automatic, "Auto");
GUILayout.FlexibleSpace();
automaticProp.boolValue = automatic;
EditorGUILayout.EndHorizontal();
if (automatic == false)
{
EditorGUILayout.PropertyField(minProp);
if (minProp.doubleValue > maxProp.doubleValue)
minProp.doubleValue = maxProp.doubleValue - 0.1;
}
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(MaxBarValue, EditorStyles.boldLabel);
automaticProp = barData.FindPropertyRelative("automaticMaxValue");
automatic = automaticProp.boolValue;
automatic = GUILayout.Toggle(automatic, "Auto");
GUILayout.FlexibleSpace();
automaticProp.boolValue = automatic;
EditorGUILayout.EndHorizontal();
if (automatic == false)
{
EditorGUILayout.PropertyField(maxProp);
if (minProp.doubleValue > maxProp.doubleValue)
maxProp.doubleValue = minProp.doubleValue + 0.1;
}
if (GUILayout.Button("Edit Values...") && mWindow == null)
mWindow = ChartDataEditor.ShowForObject(serializedObject);
//}
EditorGUI.indentLevel--;
EditorGUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
if (mUpdateWindow == true)
{
mUpdateWindow = false;
if (mWindow != null)
{
mWindow.SetEditedObject(serializedObject);
mWindow.Repaint();
}
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 056f0fff5e172de468df8c3392cabaac
timeCreated: 1473969758
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,68 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace ChartAndGraph
{
[CustomPropertyDrawer(typeof(GraphDataFiller.CategoryData))]
class CategoryDataEditor : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2f;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
var enabled = property.FindPropertyRelative("Enabled");
property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, property.displayName);
if(property.isExpanded)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(enabled);
if (enabled.boolValue == true)
{
var dataType = property.FindPropertyRelative("DataType");
EditorGUILayout.PropertyField(dataType);
int item = dataType.enumValueIndex;
var iterator = property.Copy();
var end = iterator.GetEndProperty();
bool hasNext = iterator.NextVisible(true);
Type t = typeof(GraphDataFiller.CategoryData);
while (hasNext)
{
if ((SerializedProperty.EqualContents(iterator, end)))
break;
bool show = false;
foreach (object attrb in t.GetField(iterator.name).GetCustomAttributes(false))
{
var cast = attrb as ChartFillerEditorAttribute;
if (cast != null)
{
if ((int)cast.ShowForType == item)
{
show = true;
break;
}
}
}
if (show)
EditorGUILayout.PropertyField(iterator);
// Debug.Log(iterator.displayName);
hasNext = iterator.NextVisible(false);
}
}
}
EditorGUI.indentLevel--;
EditorGUI.EndProperty();
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: d7ad20a161538c146aa76559c3f89754
timeCreated: 1536697084
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,26 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
namespace ChartAndGraph
{
[CustomEditor(typeof(CategoryLabels))]
class CategoryLabelsLabelsInspector : ItemLabelsBaseEditor
{
protected override string Name
{
get
{
return "category labels";
}
}
protected override bool isSupported(AnyChart chart)
{
return ((IInternalUse)chart).InternalSupportsCategoryLables;
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 31ece195e6c596940a2dd7720c53058e
timeCreated: 1480254476
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,96 +0,0 @@
#define Graph_And_Chart_PRO
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class ChartDataEditor : UnityEditor.EditorWindow
{
SerializedObject mEditedObject;
SerializedProperty mBarData;
SerializedProperty mCategories;
SerializedProperty mGroups;
SerializedProperty mData;
Dictionary<string, SerializedProperty> mValues;
public static ChartDataEditor ShowForObject(SerializedObject obj)
{
ChartDataEditor window = (ChartDataEditor)EditorWindow.GetWindow(typeof(ChartDataEditor));
window.SetEditedObject(obj);
return window;
}
public void SetEditedObject(SerializedObject obj)
{
mEditedObject = obj;
mBarData = mEditedObject.FindProperty("Data");
mCategories = mBarData.FindPropertyRelative("mCategories");
mGroups = mBarData.FindPropertyRelative("mGroups");
mData = mBarData.FindPropertyRelative("mData");
LoadData();
}
void LoadData()
{
if(mValues == null)
mValues = new Dictionary<string, SerializedProperty>();
mValues.Clear();
int size = mData.arraySize;
for (int i = 0; i < size; i++)
{
SerializedProperty prop = mData.GetArrayElementAtIndex(i);
string columnName = prop.FindPropertyRelative("ColumnName").stringValue;
string rowName = prop.FindPropertyRelative("GroupName").stringValue;
SerializedProperty amount = prop.FindPropertyRelative("Amount");
string keyName = getKey(columnName, rowName);
mValues[keyName] = amount;
}
}
string getKey(string column,string row)
{
return string.Format("{0}|{1}", column, row);
}
void OnGUI()
{
GUILayout.Label("Edit Values", EditorStyles.boldLabel);
GUILayout.BeginVertical();
int categoryCount = mCategories.arraySize;
int groupCount = mGroups.arraySize;
GUILayout.BeginHorizontal();
GUILayout.Label(" ",GUILayout.Width(EditorGUIUtility.fieldWidth));
for (int i = 0; i < groupCount; i++)
{
string group = mGroups.GetArrayElementAtIndex(i).stringValue;
GUILayout.Label(group, GUILayout.Width(EditorGUIUtility.fieldWidth));
}
GUILayout.EndHorizontal();
for (int i=0; i<categoryCount; i++)
{
SerializedProperty catProp = mCategories.GetArrayElementAtIndex(i);
string category = catProp.FindPropertyRelative("Name").stringValue;
GUILayout.BeginHorizontal();
GUILayout.Label(category, GUILayout.Width(EditorGUIUtility.fieldWidth));
for (int j=0; j<groupCount; j++)
{
string group = mGroups.GetArrayElementAtIndex(j).stringValue;
string keyName = getKey(category, group);
double value =0.0;
SerializedProperty prop;
if (mValues.TryGetValue(keyName, out prop))
value = prop.doubleValue;
else
prop = null;
double newVal = EditorGUILayout.DoubleField(value, GUILayout.Width(EditorGUIUtility.fieldWidth));
if(newVal != value)
prop.doubleValue = newVal;
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
mEditedObject.ApplyModifiedProperties();
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: b917e1b2904ebf348a64f64b59a51908
timeCreated: 1474501984
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,38 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using UnityEngine;
namespace ChartAndGraph
{
class ChartEditorCommon
{
internal static bool IsAlphaNum(string str)
{
if (string.IsNullOrEmpty(str))
return false;
for (int i = 0; i < str.Length; i++)
{
if (!(char.IsLetter(str[i])) && (!(char.IsNumber(str[i]))) && str[i] != ' ')
return false;
}
return true;
}
internal static bool HasAttributeOfType(Type type, string fieldName, Type attributeType)
{
FieldInfo inf = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
if (inf == null)
return false;
object[] attrb = inf.GetCustomAttributes(attributeType, true);
if (attrb == null)
return false;
return attrb.Length > 0;
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 7fc5bc09e01eda34da606695525bf023
timeCreated: 1479124371
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,58 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using ChartAndGraph;
using UnityEngine;
[CustomPropertyDrawer(typeof(ChartOrientedSize))]
class ChartOrientedSizeInspector : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUIUtility.singleLineHeight * 2;
}
void DoField(SerializedProperty prop, string label, Rect position)
{
float size = GUI.skin.label.CalcSize(new GUIContent(label)).x;
Rect labelRect = new Rect(position.x, position.y, size, position.height);
Rect FieldRect = new Rect(labelRect.xMax, position.y, position.width - size, position.height);
EditorGUI.LabelField(labelRect, label);
float val = prop.floatValue;
EditorGUI.LabelField(labelRect, label);
float labelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 5;
val = EditorGUI.FloatField(FieldRect, " ", val);
EditorGUIUtility.labelWidth = labelWidth;
prop.floatValue = val;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
label = EditorGUI.BeginProperty(position, label, property);
EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
position = EditorGUI.IndentedRect(position);
float halfWidth = position.width *0.5f;
float y = position.y + EditorGUIUtility.singleLineHeight;
float height = position.height - EditorGUIUtility.singleLineHeight;
Rect breadthRect = new Rect(position.x, y, halfWidth, height);
Rect depthRect = new Rect(breadthRect.xMax, y, halfWidth, height);
int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel=0;
SerializedProperty breadth = property.FindPropertyRelative("Breadth");
SerializedProperty depth = property.FindPropertyRelative("Depth");
DoField(breadth, "Breadth:", breadthRect);
DoField(depth, "Depth:", depthRect);
EditorGUI.indentLevel = indent;
// EditorGUILayout.EndVertical();
EditorGUI.EndProperty();
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 6f48c9091dc0c084595117abe8222c22
timeCreated: 1473684701
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,60 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace ChartAndGraph
{
partial class EditorMenu
{
private static void InstanciateWorldSpace(string path)
{
GameObject obj = Resources.Load<GameObject>(path);
// GameObject obj = AssetDatabase.LoadAssetAtPath<GameObject>(path);
GameObject newObj = (GameObject)GameObject.Instantiate(obj);
newObj.name = newObj.name.Replace("(Clone)", "");
Undo.RegisterCreatedObjectUndo(newObj, "Create Object");
}
[MenuItem("Tools/Charts/Radar/3D")]
public static void AddRadarChartWorldSpace()
{
InstanciateWorldSpace("MenuPrefabs/3DRadar");
}
[MenuItem("Tools/Charts/Bar/3D/Simple")]
public static void AddBarChartSimple3D()
{
InstanciateWorldSpace("MenuPrefabs/Bar3DSimple");
}
[MenuItem("Tools/Charts/Bar/3D/Multiple Groups")]
public static void AddBarChartMultiple3D()
{
InstanciateWorldSpace("MenuPrefabs/Bar3DMultiple");
}
[MenuItem("Tools/Charts/Torus/3D")]
public static void AddTorusChart3D()
{
InstanciateWorldSpace("MenuPrefabs/Torus3D");
}
[MenuItem("Tools/Charts/Pie/3D")]
public static void AddPieChart3D()
{
InstanciateWorldSpace("MenuPrefabs/Pie3D");
}
[MenuItem("Tools/Charts/Graph/3D")]
public static void AddGraph3D()
{
InstanciateWorldSpace("MenuPrefabs/3DGraph");
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 128e6b85597fded4f886f1f5aea62b53
timeCreated: 1560597478
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,113 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace ChartAndGraph
{
partial class EditorMenu
{
private static void InstanciateCanvas(string path)
{
Canvas[] canvases = GameObject.FindObjectsOfType<Canvas>();
if (canvases == null || canvases.Length == 0)
{
EditorUtility.DisplayDialog("No canvas in scene", "Please add a canvas to the scene and try again", "Ok");
return;
}
Canvas canvas = null;
foreach(Canvas c in canvases)
{
if(c.transform.parent == null)
{
canvas = c;
break;
}
}
if (canvas == null)
{
EditorUtility.DisplayDialog("No canvas in scene", "Please add a canvas to the scene and try again", "Ok");
return;
}
GameObject obj = Resources.Load<GameObject>(path);
GameObject newObj = (GameObject)GameObject.Instantiate(obj);
newObj.transform.SetParent(canvas.transform,false);
newObj.name = newObj.name.Replace("(Clone)","");
Undo.RegisterCreatedObjectUndo(newObj, "Create Object");
}
[MenuItem("Tools/Charts/Clear All")]
public static void ClearChartGarbage()
{
ChartItem[] children = GameObject.FindObjectsOfType<ChartItem>();
for (int i = 0; i < children.Length; ++i)
{
if (children[i] != null)
{
ChartCommon.SafeDestroy(children[i].gameObject);
}
}
}
[MenuItem("Tools/Charts/Radar/Canvas")]
public static void AddRadarChartCanvas()
{
InstanciateCanvas("MenuPrefabs/2DRadar");
}
[MenuItem("Tools/Charts/Bar/Canvas/Simple")]
public static void AddBarChartSimpleCanvas()
{
InstanciateCanvas("MenuPrefabs/BarCanvasSimple");
}
[MenuItem("Tools/Charts/Bar/Canvas/Multiple Groups")]
public static void AddBarChartMultipleCanvas()
{
InstanciateCanvas("MenuPrefabs/BarCanvasMultiple");
}
[MenuItem("Tools/Charts/Torus/Canvas")]
public static void AddTorusChartCanvas()
{
InstanciateCanvas("MenuPrefabs/TorusCanvas");
}
[MenuItem("Tools/Charts/Pie/Canvas")]
public static void AddPieChartCanvas()
{
InstanciateCanvas("MenuPrefabs/PieCanvas");
}
[MenuItem("Tools/Charts/Graph/Canvas/Simple")]
public static void AddGraphSimple()
{
InstanciateCanvas("MenuPrefabs/GraphSimple");
}
[MenuItem("Tools/Charts/Graph/Canvas/Multiple")]
public static void AddGraphMultiple()
{
InstanciateCanvas("MenuPrefabs/GraphMultiple");
}
[MenuItem("Tools/Charts/Legend")]
public static void AddChartLegend()
{
InstanciateCanvas("MenuPrefabs/Legend");
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 57e0bbe359ea30c4d814819575d1a81d
timeCreated: 1481803595
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,399 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace ChartAndGraph
{
[CustomEditor(typeof(GraphChartBase), true)]
class GraphChartInspector : Editor
{
string mEditedCategory = "";
bool mCategories = false;
string mCategoryError = null;
string mNewCategoryName = "";
GUIStyle mRedStyle;
GUIStyle mBold;
HashSet<string> mAllNames = new HashSet<string>();
GUIStyle mSplitter;
List<int> mToRemove = new List<int>();
List<int> mToUp = new List<int>();
Dictionary<string, string> mOperations = new Dictionary<string, string>();
Texture mSettings;
GraphDataEditor mWindow;
RenameWindow mRenameWindow = null;
public void OnEnable()
{
mRedStyle = new GUIStyle();
mRedStyle.normal.textColor = Color.red;
mSplitter = new GUIStyle();
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
mSplitter.stretchWidth = true;
mSplitter.margin = new RectOffset(0, 0, 7, 7);
}
public void Splitter()
{
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
if (Event.current.type == EventType.Repaint)
{
Color restoreColor = GUI.color;
GUI.color = new Color(0.5f, 0.5f, 0.5f);
mSplitter.Draw(position, false, false, false, false);
GUI.color = restoreColor;
}
}
private static bool IsAlphaNum(string str)
{
if (string.IsNullOrEmpty(str))
return false;
for (int i = 0; i < str.Length; i++)
{
if (!(char.IsLetter(str[i])) && (!(char.IsNumber(str[i]))) && str[i] != ' ')
return false;
}
return true;
}
private void DoOperations(SerializedProperty items, int size, string type)
{
mToRemove.Clear();
mToUp.Clear();
bool up = false;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
string arg = type + "|" + name;
string res = null;
if (up == true)
{
mToUp.Add(i);
up = false;
}
if (mOperations.TryGetValue(arg, out res))
{
if (res == "remove")
mToRemove.Add(i);
if (res == "up" && i > 0)
mToUp.Add(i);
if (res == "down")
up = true;
mOperations.Remove(arg);
}
}
for (int i = 0; i < mToRemove.Count; i++)
{
items.DeleteArrayElementAtIndex(mToRemove[i]);
}
for (int i = 0; i < mToUp.Count; i++)
{
int cur = mToUp[i];
items.MoveArrayElement(cur, cur - 1);
}
}
private void DataEditor(SerializedProperty data, string type, string property, string caption)
{
}
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
{
SerializedProperty items = data.FindPropertyRelative(property);
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
//bool up, down;
mAllNames.Clear();
int size = items.arraySize;
if (Event.current.type == EventType.Layout)
DoOperations(items, size, type);
size = items.arraySize;
if (items.isExpanded)
{
EditorGUI.indentLevel++;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
mAllNames.Add(name);
bool toogle = false;
EditorGUILayout.BeginHorizontal();
if (nameProp != null)
toogle = entry.isExpanded = EditorGUILayout.Foldout(entry.isExpanded, name);
else
{
toogle = false;
EditorGUILayout.LabelField(name);
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("..."))
DoContext(type, name);
EditorGUILayout.EndHorizontal();
if (toogle)
{
EditorGUI.indentLevel++;
if (nameProp != null)
{
SerializedProperty end = entry.GetEndProperty(true);
entry.Next(true);
if (SerializedProperty.EqualContents(entry, end) == false)
{
do
{
if (entry.name != "Name" && entry.name != "data")
{
if (entry.name == "ViewOrder")
continue;
if (target is GraphChart) // canvas graph chart
{
if ((entry.name == "LinePrefab") || (entry.name == "FillPrefab") || (entry.name == "DotPrefab") || (entry.name == "Depth"))
{
continue;
}
}
else
{
if ((entry.name == "LineHoverPrefab") || (entry.name == "PointHoverPrefab"))
continue;
}
EditorGUILayout.PropertyField(entry, true);
}
}
while (entry.Next(false) && SerializedProperty.EqualContents(entry, end) == false);
GUILayout.BeginHorizontal();
GUILayout.Space(EditorGUI.IndentedRect(EditorGUILayout.GetControlRect()).xMin);
if (GUILayout.Button("Edit Values..."))
{
mEditedCategory = name;
if (mWindow == null)
mWindow = GraphDataEditor.ShowForObject(serializedObject, mEditedCategory);
}
GUILayout.EndHorizontal();
}
}
EditorGUI.indentLevel--;
}
}
if (errorMessage != null)
EditorGUILayout.LabelField(errorMessage, mRedStyle);
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
EditorGUILayout.BeginHorizontal();
newName = EditorGUILayout.TextField(newName);
//GUILayout.Space(indentAdd.xMin);
if (GUILayout.Button("Add"))
{
bool error = false;
if (newName.Trim().Length == 0)
{
errorMessage = "Name can't be empty";
error = true;
}
else if (IsAlphaNum(newName) == false)
{
errorMessage = "Name conatins invalid characters";
error = true;
}
else if (mAllNames.Contains(newName))
{
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
error = true;
}
if (error == false)
{
errorMessage = null;
items.InsertArrayElementAtIndex(size);
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
if (newItemName == null)
newItem.stringValue = newName;
else
newItemName.stringValue = newName;
newName = "";
UpdateWindow();
}
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
else
{
errorMessage = null;
}
UpdateWindow();
}
void callback(object val)
{
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
mOperations[pair.Key] = pair.Value;
}
bool RenameCategory(string oldName, string newName)
{
GraphChartBase graph = (GraphChartBase)serializedObject.targetObject;
try
{
graph.DataSource.RenameCategory(oldName, newName);
}
catch (Exception)
{
return false;
}
serializedObject.Update();
if (graph.gameObject.activeInHierarchy)
graph.GenerateChart();
else
EditorUtility.SetDirty(graph);
return true;
}
void RenameCalled(object val)
{
var data = (KeyValuePair<string, string>)val;
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
mRenameWindow = window;
window.ShowDialog(data.Value, data.Key, RenameCategory);
}
void DoContext(string type, string name)
{
string arg = type + "|" + name;
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Move Up"), false, callback, new KeyValuePair<string, string>(arg, "up"));
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
menu.ShowAsContext();
}
void UpdateWindow()
{
}
void OnDisable()
{
if (mRenameWindow != null)
{
mRenameWindow.Close();
mRenameWindow = null;
}
if (mWindow != null)
{
mWindow.Close();
mWindow = null;
}
}
public override void OnInspectorGUI()
{
//serializedObject.Update();
DrawDefaultInspector();
SerializedProperty autoScrollHorizontally = serializedObject.FindProperty("autoScrollHorizontally");
SerializedProperty horizontalScrolling = serializedObject.FindProperty("horizontalScrolling");
SerializedProperty autoScrollVertically = serializedObject.FindProperty("autoScrollVertically");
SerializedProperty verticalScrolling = serializedObject.FindProperty("verticalScrolling");
// SerializedProperty scrollable = serializedObject.FindProperty("scrollable");
// EditorGUILayout.PropertyField(scrollable);
// if (scrollable.boolValue == true)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(autoScrollHorizontally);
if (autoScrollHorizontally.boolValue == false)
EditorGUILayout.PropertyField(horizontalScrolling);
EditorGUILayout.PropertyField(autoScrollVertically);
if (autoScrollVertically.boolValue == false)
EditorGUILayout.PropertyField(verticalScrolling);
EditorGUI.indentLevel--;
}
SerializedProperty graphData = serializedObject.FindProperty("Data");
EditorGUILayout.BeginVertical();
Splitter();
if (mBold == null)
mBold = new GUIStyle(EditorStyles.foldout);
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
NamedItemEditor(graphData, "category", "mSerializedData", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
EditorGUI.indentLevel--;
SerializedProperty horizontalOrigin = graphData.FindPropertyRelative("horizontalViewOrigin");
SerializedProperty horizontalSize = graphData.FindPropertyRelative("horizontalViewSize");
SerializedProperty automaticcHorizontaViewGap = graphData.FindPropertyRelative("automaticcHorizontaViewGap");
SerializedProperty verticalOrigin = graphData.FindPropertyRelative("verticalViewOrigin");
SerializedProperty verticalSize = graphData.FindPropertyRelative("verticalViewSize");
SerializedProperty automaticVerticalViewGap = graphData.FindPropertyRelative("automaticVerticalViewGap");
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Horizontal View", EditorStyles.boldLabel);
SerializedProperty automaticProp = graphData.FindPropertyRelative("automaticHorizontalView");
EditorGUILayout.PropertyField(automaticProp, new GUIContent("Auto"));
bool automatic = automaticProp.boolValue;
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
if (automatic == false)
{
EditorGUILayout.PropertyField(horizontalOrigin);
EditorGUILayout.PropertyField(horizontalSize);
// if (horizontalSize.doubleValue < 0.0)
// horizontalSize.doubleValue = 0.0001;
}
else
{
EditorGUILayout.PropertyField(automaticcHorizontaViewGap, new GUIContent("Horizontal Gap"));
}
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Vertical View", EditorStyles.boldLabel);
automaticProp = graphData.FindPropertyRelative("automaticVerticallView");
EditorGUILayout.PropertyField(automaticProp, new GUIContent("Auto"));
automatic = automaticProp.boolValue;
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
if (automatic == false)
{
EditorGUILayout.PropertyField(verticalOrigin);
EditorGUILayout.PropertyField(verticalSize);
// if (verticalSize.doubleValue < 0.0)
// verticalSize.doubleValue = 0.0001;
}
else
{
EditorGUILayout.PropertyField(automaticVerticalViewGap, new GUIContent("Vertical Gap"));
}
EditorGUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
if (mWindow != null)
{
mWindow.SetEditedObject(serializedObject, mEditedCategory);
mWindow.Repaint();
}
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 8671bd55b44fd0d46ad162bc055df077
timeCreated: 1480533379
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,98 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
class GraphDataEditor : UnityEditor.EditorWindow
{
SerializedObject mThisObject;
SerializedObject mEditedObject;
string category;
SerializedProperty mGraphData;
SerializedProperty mCategories;
SerializedProperty mCategory;
Dictionary<string, SerializedProperty> mValues;
SerializedObject mObject;
[SerializeField]
Vector2[] Data;
public static GraphDataEditor ShowForObject(SerializedObject obj,string category)
{
GraphDataEditor window = (GraphDataEditor)EditorWindow.GetWindow(typeof(GraphDataEditor));
window.SetEditedObject(obj, category);
return window;
}
int FindCategoryIndex(string category)
{
for(int i=0; i<mCategories.arraySize; i++)
{
string name = mCategories.GetArrayElementAtIndex(i).FindPropertyRelative("Name").stringValue;
if (name == category)
return i;
}
return -1;
}
public void SetEditedObject(SerializedObject obj,string categoryName)
{
category = categoryName;
mEditedObject = obj;
mGraphData = mEditedObject.FindProperty("Data");
mCategories = mGraphData.FindPropertyRelative("mSerializedData");
// LoadData();
int catIndex = FindCategoryIndex(categoryName);
if (catIndex == -1)
{
mCategory = null;
return;
}
mCategory = mCategories.GetArrayElementAtIndex(catIndex);
var arr = mCategory.FindPropertyRelative("InitialData");
mThisObject = new SerializedObject(this);
SerializedProperty serialProp = mThisObject.FindProperty("Data");
SetArray(arr, serialProp);
}
string getKey(string column, string row)
{
return string.Format("{0}|{1}", column, row);
}
void ShowCategoryArray()
{
}
void SetArray(SerializedProperty from,SerializedProperty to)
{
to.arraySize = from.arraySize;
for (int i = 0; i < from.arraySize; i++)
{
Vector2 val = from.GetArrayElementAtIndex(i).vector2Value;
to.GetArrayElementAtIndex(i).vector2Value = val;
}
}
void OnGUI()
{
SerializedProperty serialProp = mThisObject.FindProperty("Data");
GUILayout.Label("Edit Values - " + category, EditorStyles.boldLabel);
if (mCategory == null)
return;
EditorGUILayout.PropertyField(serialProp, true);
var arr = mCategory.FindPropertyRelative("InitialData");
if (mThisObject.ApplyModifiedProperties())
SetArray(serialProp,arr);
mEditedObject.ApplyModifiedProperties();
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 03f0eb5ac4118424f8d68f32ef5ffa1b
timeCreated: 1584550686
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,36 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
namespace ChartAndGraph
{
[CustomEditor(typeof(GraphDataFiller), true)]
class GraphDataFillerEditor : Editor
{
/*
*
*
*
*
*
* This is a work around and must not be deleteed
*
*
*
*
*
* */
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
// var cats = serializedObject.FindProperty("Categories");
// EditorGUILayout.PropertyField(cats);
// CategoryDataEditor
// Categories
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 05791da4c4a2fc44281046536e32e237
timeCreated: 1560715350
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,26 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
namespace ChartAndGraph
{
[CustomEditor(typeof(GroupLabels))]
class GroupLabelsInspector : ItemLabelsBaseEditor
{
protected override string Name
{
get
{
return "group labels";
}
}
protected override bool isSupported(AnyChart chart)
{
return ((IInternalUse)chart).InternalSupportsGroupLabels;
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 1a56a06b898a879418ba574600eaf84a
timeCreated: 1480254476
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,35 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
namespace ChartAndGraph
{
abstract class ItemLabelsBaseEditor : Editor
{
protected abstract string Name { get; }
protected abstract bool isSupported(AnyChart chart);
public override void OnInspectorGUI()
{
ItemLabelsBase labels = (ItemLabelsBase)target;
if (labels.gameObject == null)
return;
AnyChart chart = labels.gameObject.GetComponent<AnyChart>();
if (chart == null)
return;
if (isSupported(chart) == false)
{
EditorGUILayout.HelpBox(string.Format("Chart of type {0} does not support {1}", chart.GetType().Name,Name),MessageType.Warning);
return;
}
base.OnInspectorGUI();
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 67d1379f880dde846adec8a6157669d1
timeCreated: 1480254476
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,26 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
namespace ChartAndGraph
{
[CustomEditor(typeof(ItemLabels))]
class ItemLabelsLabelsInspector : ItemLabelsBaseEditor
{
protected override string Name
{
get
{
return "item labels";
}
}
protected override bool isSupported(AnyChart chart)
{
return ((IInternalUse)chart).InternalSupportsItemLabels;
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 12cb0562684057a448410b90a0e565f8
timeCreated: 1480254476
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,40 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace ChartAndGraph
{
[CustomPropertyDrawer(typeof(MaterialTiling))]
class MaterialTilingInspector : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
label = EditorGUI.BeginProperty(position, label, property);
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
SerializedProperty auto = property.FindPropertyRelative("EnableTiling");
SerializedProperty val = property.FindPropertyRelative("TileFactor");
int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
bool res = !EditorGUI.ToggleLeft(position,"Stretch", !auto.boolValue);
EditorGUI.indentLevel = indent;
//EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel++;
if (auto.boolValue == true && EditorGUI.showMixedValue == false)
{
EditorGUILayout.HelpBox("Remember to enable texture repeat mode in order to make tiling work !",MessageType.Warning,true);
EditorGUILayout.HelpBox("For the best results on canvas , set the tiling factor to the pixel size of the textre", MessageType.Info, true);
val.floatValue = EditorGUILayout.FloatField("Tiling Factor",val.floatValue);
if (val.floatValue <= 0f)
val.floatValue = 0.01f;
}
auto.boolValue = res;
EditorGUI.indentLevel--;
EditorGUI.EndProperty();
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 7c894d939d8cec94fa27b4e6b437e6bc
timeCreated: 1479370450
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,326 +0,0 @@
#define Graph_And_Chart_PRO
using ChartAndGraph;
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(PieChart), true)]
class PieChartInspetor : Editor
{
bool mCategories = false;
string mCategoryError = null;
string mNewCategoryName = "";
GUIStyle mRedStyle;
GUIStyle mBold;
HashSet<string> mAllNames = new HashSet<string>();
GUIStyle mSplitter;
List<int> mToRemove = new List<int>();
List<int> mToUp = new List<int>();
Dictionary<string, string> mOperations = new Dictionary<string, string>();
ChartDataEditor mWindow;
bool mUpdateWindow = false;
Texture mSettings;
RenameWindow mRenameWindow = null;
public void OnEnable()
{
mRedStyle = new GUIStyle();
mRedStyle.normal.textColor = Color.red;
mSplitter = new GUIStyle();
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
mSplitter.stretchWidth = true;
mSplitter.margin = new RectOffset(0, 0, 7, 7);
}
public void Splitter()
{
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
if (Event.current.type == EventType.Repaint)
{
Color restoreColor = GUI.color;
GUI.color = new Color(0.5f, 0.5f, 0.5f);
mSplitter.Draw(position, false, false, false, false);
GUI.color = restoreColor;
}
}
private static bool IsAlphaNum(string str)
{
if (string.IsNullOrEmpty(str))
return false;
for (int i = 0; i < str.Length; i++)
{
if (!(char.IsLetter(str[i])) && (!(char.IsNumber(str[i]))) && str[i] != ' ')
return false;
}
return true;
}
private void DoOperations(SerializedProperty items, int size, string type)
{
mToRemove.Clear();
mToUp.Clear();
bool up = false;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
string arg = type + "|" + name;
string res = null;
if (up == true)
{
mToUp.Add(i);
up = false;
}
if (mOperations.TryGetValue(arg, out res))
{
if (res == "remove")
mToRemove.Add(i);
if (res == "up" && i > 0)
mToUp.Add(i);
if (res == "down")
up = true;
mOperations.Remove(arg);
}
}
for (int i = 0; i < mToRemove.Count; i++)
items.DeleteArrayElementAtIndex(mToRemove[i]);
for (int i = 0; i < mToUp.Count; i++)
{
int cur = mToUp[i];
items.MoveArrayElement(cur, cur - 1);
}
}
private SerializedProperty getArrayCategory(SerializedProperty arr, string name)
{
for (int i = 0; i < arr.arraySize; i++)
{
SerializedProperty prop = arr.GetArrayElementAtIndex(i);
if (prop.FindPropertyRelative("ColumnName").stringValue == name)
return prop.FindPropertyRelative("Amount");
}
return null;
}
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
{
SerializedProperty items = data.FindPropertyRelative(property);
SerializedProperty dataValues = data.FindPropertyRelative("mData");
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
//bool up, down;
mAllNames.Clear();
int size = items.arraySize;
if (Event.current.type == EventType.Layout)
DoOperations(items, size, type);
size = items.arraySize;
if (items.isExpanded)
{
EditorGUI.indentLevel++;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
mAllNames.Add(name);
bool toogle = false;
EditorGUILayout.BeginHorizontal();
if (nameProp != null)
toogle = entry.isExpanded =EditorGUILayout.Foldout(entry.isExpanded, name);
else
{
toogle = false;
EditorGUILayout.LabelField(name);
}
SerializedProperty valueProp = getArrayCategory(dataValues, name);
GUILayout.FlexibleSpace();
if(valueProp != null)
EditorGUILayout.PropertyField(valueProp);
if (GUILayout.Button("..."))
DoContext(type, name);
EditorGUILayout.EndHorizontal();
if (toogle)
{
EditorGUI.indentLevel++;
if (nameProp != null)
{
SerializedProperty end = entry.GetEndProperty(true);
entry.Next(true);
if (SerializedProperty.EqualContents(entry, end) == false)
{
do
{
if (entry.name != "Name")
EditorGUILayout.PropertyField(entry, true);
}
while (entry.Next(entry.name == "Materials") && SerializedProperty.EqualContents(entry, end) == false);
}
}
EditorGUI.indentLevel--;
}
}
if (errorMessage != null)
EditorGUILayout.LabelField(errorMessage, mRedStyle);
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
EditorGUILayout.BeginHorizontal();
newName = EditorGUILayout.TextField(newName);
//GUILayout.Space(indentAdd.xMin);
if (GUILayout.Button("Add"))
{
bool error = false;
if (newName.Trim().Length == 0)
{
errorMessage = "Name can't be empty";
error = true;
}
else if (IsAlphaNum(newName) == false)
{
errorMessage = "Name conatins invalid characters";
error = true;
}
else if (mAllNames.Contains(newName))
{
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
error = true;
}
if (error == false)
{
errorMessage = null;
items.InsertArrayElementAtIndex(size);
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
if (newItemName == null)
newItem.stringValue = newName;
else
newItemName.stringValue = newName;
newName = "";
UpdateWindow();
}
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
else
{
errorMessage = null;
}
UpdateWindow();
}
void callback(object val)
{
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
mOperations[pair.Key] = pair.Value;
}
bool RenameCategory(string fromName, string toName)
{
PieChart pieChart = (PieChart)serializedObject.targetObject;
try
{
pieChart.DataSource.RenameCategory(fromName, toName);
}
catch (Exception)
{
return false;
}
serializedObject.Update();
if (pieChart.gameObject.activeInHierarchy)
pieChart.GenerateChart();
else
EditorUtility.SetDirty(pieChart);
return true;
}
void RenameCalled(object val)
{
var data = (KeyValuePair<string, string>)val;
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
mRenameWindow = window;
if (data.Key == "category")
window.ShowDialog(data.Value, data.Key, RenameCategory);
}
void DoContext(string type, string name)
{
string arg = type + "|" + name;
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Move Up"), false, callback, new KeyValuePair<string, string>(arg, "up"));
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
menu.ShowAsContext();
}
void UpdateWindow()
{
mUpdateWindow = true;
}
void OnDisable()
{
if(mRenameWindow != null)
{
mRenameWindow.Close();
mRenameWindow = null;
}
if (mWindow != null)
{
mWindow.Close();
mWindow = null;
}
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.Update();
SerializedProperty barData = serializedObject.FindProperty("Data");
EditorGUILayout.BeginVertical();
Splitter();
if (mBold == null)
mBold = new GUIStyle(EditorStyles.foldout);
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
NamedItemEditor(barData, "category", "mCategories", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
EditorGUI.indentLevel--;
EditorGUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
if (mUpdateWindow == true)
{
mUpdateWindow = false;
if (mWindow != null)
{
mWindow.SetEditedObject(serializedObject);
mWindow.Repaint();
}
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: dcc024b6935dfff44aece802ded95e9a
timeCreated: 1480008753
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 8ef85873de9c3f742b12f175025aed9a
folderAsset: yes
timeCreated: 1539558023
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,71 +0,0 @@
#define Graph_And_Chart_PRO
#if PLAYMAKER
using UnityEngine;
using UnityEditor;
using HutongGames.PlayMaker.Actions;
using HutongGames.PlayMakerEditor;
[CustomActionEditor(typeof(AppendGraphPointAction))]
public class CustomActionEditorTest : CustomActionEditor
{
enum DateOrNumeric
{
Numeric,
Date
}
public override void OnEnable()
{
// Do any expensive initialization stuff here.
// This is called when the editor is created.
}
public override bool OnGUI()
{
var action = target as AppendGraphPointAction;
EditField("ChartObject");
EditField("CategoryName");
EditField("AnimationTime");
EditField("DateTimeKind");
EditField("PointSize");
EditorGUILayout.LabelField("X value:");
DateOrNumeric type = DateOrNumeric.Numeric;
if (action.XValueIsDate)
type = DateOrNumeric.Date;
type = (DateOrNumeric)EditorGUILayout.EnumPopup("type", type);
action.XValueIsDate = type == DateOrNumeric.Date;
if (action.XValueIsDate)
{
EditField("XDateYear");
EditField("XDateMonth");
EditField("XDateDay");
EditField("XDateHour");
EditField("XDateMinute");
EditField("XDateSecond");
}
else
EditField("XValueFloat");
EditorGUILayout.LabelField("Y value:");
type = DateOrNumeric.Numeric;
if (action.YValueIsDate)
type = DateOrNumeric.Date;
type = (DateOrNumeric)EditorGUILayout.EnumPopup("type", type);
action.YValueIsDate = type == DateOrNumeric.Date;
if (action.YValueIsDate)
{
EditField("YDateYear");
EditField("YDateMonth");
EditField("YDateDay");
EditField("YDateHour");
EditField("YDateMinute");
EditField("YDateSecond");
}
else
EditField("YValueFloat");
return GUI.changed;
}
}
#endif

View File

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

View File

@ -1,83 +0,0 @@
#define Graph_And_Chart_PRO
#if UNITY_2018_3_OR_NEWER
#if UNITY_EDITOR
using UnityEngine;
using System.Collections;
using UnityEditor;
using ChartAndGraph;
public class PrefabOverrideChart : UnityEditor.AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
foreach (string path in importedAssets)
{
string lowPath = path.ToLower();
if (lowPath.EndsWith(".prefab"))
{
if (ContainsPath(lowPath) == false)
{
// Debug.Log(lowPath);
EditorApplication.delayCall += () => CleanPrefab(path);
AddPath(lowPath);
}
}
}
foreach (string path in deletedAssets)
{
RemovePath(path.ToLower());
}
}
[MenuItem("EditorPrefs/Clear all Editor Preferences")]
static void deleteAllExample()
{
EditorPrefs.DeleteAll();
}
static bool ContainsPath(string path)
{
return EditorPrefs.GetBool("GraphAndChartPrefabOverride$" + path, false);
}
static void RemovePath(string path)
{
EditorPrefs.DeleteKey("GraphAndChartPrefabOverride$" + path);
}
static void AddPath(string path)
{
EditorPrefs.SetBool("GraphAndChartPrefabOverride$" + path, true);
}
static void CleanPrefab(string path)
{
GameObject obj = PrefabUtility.LoadPrefabContents(path);
//AssetDatabase.DeleteAsset(path);
bool savePrefab = false;
foreach (var item in obj.GetComponentsInChildren<AnyChart>(true))
{
savePrefab = true;
// if (item == null)
// continue;
// if (item.gameObject == null)
// continue;
// Debug.Log("destroy " + item.gameObject.name);
while (item.gameObject.transform.childCount > 0)
{
var innerObj = item.gameObject.transform.GetChild(0).gameObject;
if (innerObj != null)
{
// Debug.Log("destroy inner" + innerObj.name);
GameObject.DestroyImmediate(innerObj);
}
}
}
if (savePrefab)
PrefabUtility.SaveAsPrefabAsset(obj, path);
PrefabUtility.UnloadPrefabContents(obj);
}
}
#endif
#endif

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: eb3ccf7dc2806314e99c1bbc160aabec
timeCreated: 1579105195
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,375 +0,0 @@
#define Graph_And_Chart_PRO
using ChartAndGraph;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace Assets
{
[CustomEditor(typeof(RadarChart), true)]
class RadarChartInspector : UnityEditor.Editor
{
bool mCategories = false;
bool mGroups = false;
string mCategoryError = null;
string mNewCategoryName = "";
string mNewGroupName = "";
string mGroupError = null;
GUIStyle mRedStyle;
GUIStyle mBold;
HashSet<string> mAllNames = new HashSet<string>();
GUIStyle mSplitter;
List<int> mToRemove = new List<int>();
List<int> mToUp = new List<int>();
Dictionary<string, string> mOperations = new Dictionary<string, string>();
ChartDataEditor mWindow;
bool mUpdateWindow = false;
Texture mSettings;
GUIContent MaxRadarValue = new GUIContent("Max Value :", "All radar values are scale according to this value");
RenameWindow mRenameWindow;
string[] NonCanvas = new string[]
{
"LinePrefab",
"PointPrefab",
"Seperation",
"Curve",
"FillSmoothing"
};
public void OnEnable()
{
mRedStyle = new GUIStyle();
mRedStyle.normal.textColor = Color.red;
mSplitter = new GUIStyle();
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
mSplitter.stretchWidth = true;
mSplitter.margin = new RectOffset(0, 0, 7, 7);
}
public void Splitter()
{
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
if (Event.current.type == EventType.Repaint)
{
Color restoreColor = GUI.color;
GUI.color = new Color(0.5f, 0.5f, 0.5f);
mSplitter.Draw(position, false, false, false, false);
GUI.color = restoreColor;
}
}
private void DoOperations(SerializedProperty items, int size, string type)
{
mToRemove.Clear();
mToUp.Clear();
bool up = false;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
string arg = type + "|" + name;
string res = null;
if (up == true)
{
mToUp.Add(i);
up = false;
}
if (mOperations.TryGetValue(arg, out res))
{
if (res == "remove")
mToRemove.Add(i);
if (res == "up" && i > 0)
mToUp.Add(i);
if (res == "down")
up = true;
mOperations.Remove(arg);
}
}
for (int i = 0; i < mToRemove.Count; i++)
items.DeleteArrayElementAtIndex(mToRemove[i]);
for (int i = 0; i < mToUp.Count; i++)
{
int cur = mToUp[i];
items.MoveArrayElement(cur, cur - 1);
}
}
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
{
SerializedProperty items = data.FindPropertyRelative(property);
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
//bool up, down;
mAllNames.Clear();
int size = items.arraySize;
if (Event.current.type == EventType.Layout)
DoOperations(items, size, type);
size = items.arraySize;
if (items.isExpanded)
{
EditorGUI.indentLevel++;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
mAllNames.Add(name);
EditorGUILayout.BeginHorizontal();
bool toogle = false;
if (nameProp != null)
toogle = entry.isExpanded = EditorGUILayout.Foldout(entry.isExpanded, name);
else
{
toogle = false;
EditorGUILayout.LabelField(name);
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("..."))
DoContext(type, name);
EditorGUILayout.EndHorizontal();
if (toogle)
{
EditorGUI.indentLevel++;
if (nameProp != null)
{
SerializedProperty end = entry.GetEndProperty(true);
entry.Next(true);
if (SerializedProperty.EqualContents(entry, end) == false)
{
do
{
if (entry.name != "Name")
{
if(target is CanvasRadarChart)
{
if (NonCanvas.Contains(entry.name))
continue;
}
else
{
if (entry.name == "LineHover" || entry.name == "PointHover")
continue;
}
EditorGUILayout.PropertyField(entry, true);
}
}
while (entry.Next(entry.name == "Materials") && SerializedProperty.EqualContents(entry, end) == false);
}
}
EditorGUI.indentLevel--;
}
}
if (errorMessage != null)
EditorGUILayout.LabelField(errorMessage, mRedStyle);
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
EditorGUILayout.BeginHorizontal();
newName = EditorGUILayout.TextField(newName);
//GUILayout.Space(indentAdd.xMin);
if (GUILayout.Button("Add"))
{
bool error = false;
if (newName.Trim().Length == 0)
{
errorMessage = "Name can't be empty";
error = true;
}
else if (ChartEditorCommon.IsAlphaNum(newName) == false)
{
errorMessage = "Name conatins invalid characters";
error = true;
}
else if (mAllNames.Contains(newName))
{
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
error = true;
}
if (error == false)
{
errorMessage = null;
items.InsertArrayElementAtIndex(size);
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
if (newItemName == null)
newItem.stringValue = newName;
else
newItemName.stringValue = newName;
newName = "";
UpdateWindow();
}
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
else
{
errorMessage = null;
}
UpdateWindow();
}
void callback(object val)
{
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
mOperations[pair.Key] = pair.Value;
}
bool RenameGroup(string fromName, string toName)
{
RadarChart radarChart = (RadarChart)serializedObject.targetObject;
try
{
radarChart.DataSource.RenameGroup(fromName, toName);
}
catch (Exception)
{
return false;
}
serializedObject.Update();
if (radarChart.gameObject.activeInHierarchy)
radarChart.GenerateChart();
else
EditorUtility.SetDirty(radarChart);
return true;
}
bool RenameCategory(string fromName, string toName)
{
RadarChart radarChart = (RadarChart)serializedObject.targetObject;
try
{
radarChart.DataSource.RenameCategory(fromName, toName);
}
catch (Exception)
{
return false;
}
serializedObject.Update();
if (radarChart.gameObject.activeInHierarchy)
radarChart.GenerateChart();
else
EditorUtility.SetDirty(radarChart);
return true;
}
void RenameCalled(object val)
{
var data = (KeyValuePair<string, string>)val;
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
mRenameWindow = window;
if (data.Key == "category")
window.ShowDialog(data.Value, data.Key, RenameCategory);
else if (data.Key == "group")
window.ShowDialog(data.Value, data.Key, RenameGroup);
}
void DoContext(string type, string name)
{
string arg = type + "|" + name;
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Move Up"), false, callback, new KeyValuePair<string, string>(arg, "up"));
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
menu.ShowAsContext();
}
void UpdateWindow()
{
mUpdateWindow = true;
}
void OnDisable()
{
if (mRenameWindow != null)
{
mRenameWindow.Close();
mRenameWindow = null;
}
if (mWindow != null)
{
mWindow.Close();
mWindow = null;
}
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.Update();
SerializedProperty radarData = serializedObject.FindProperty("Data");
EditorGUILayout.BeginVertical();
Splitter();
if (mBold == null)
{
mBold = new GUIStyle(EditorStyles.foldout);
}
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
NamedItemEditor(radarData, "category", "mCategories", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
NamedItemEditor(radarData, "group", "mGroups", "Groups", ref mGroupError, ref mGroups, ref mNewGroupName);
SerializedProperty maxProp = radarData.FindPropertyRelative("maxValue");
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(MaxRadarValue, EditorStyles.boldLabel);
SerializedProperty automaticProp = radarData.FindPropertyRelative("automaticMaxValue");
bool automatic = automaticProp.boolValue;
automatic = GUILayout.Toggle(automatic, "Auto");
GUILayout.FlexibleSpace();
automaticProp.boolValue = automatic;
EditorGUILayout.EndHorizontal();
if (automatic == false)
{
EditorGUILayout.PropertyField(maxProp);
if (0f > maxProp.doubleValue)
maxProp.doubleValue = 0.001f;
}
if (GUILayout.Button("Edit Values...") && mWindow == null)
mWindow = ChartDataEditor.ShowForObject(serializedObject);
//}
EditorGUI.indentLevel--;
EditorGUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
if (mUpdateWindow == true)
{
mUpdateWindow = false;
if (mWindow != null)
{
mWindow.SetEditedObject(serializedObject);
mWindow.Repaint();
}
}
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: ec3a557017cfb7040b5a426cb7f71a47
timeCreated: 1489858254
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,71 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace ChartAndGraph
{
class RenameWindow :EditorWindow
{
string mStartName;
string mValue = "";
string mType;
Func<string, string, bool> mRenameMethod;
string mMessage = null;
public void ShowDialog(string currentName,string type,Func<string,string, bool> renameMethod)
{
mStartName = currentName;
mValue = currentName;
mType = type;
mRenameMethod = renameMethod;
float height = (float)(EditorGUIUtility.singleLineHeight * 6f);
minSize = maxSize = new Vector2(300, height);
Show();
}
void OnGUI()
{
EditorGUILayout.LabelField(string.Format("Select a new {0} name",mType));
mValue = EditorGUILayout.TextField(mValue);
bool disabled = false;
if (mValue.Trim().Length == 0)
{
mMessage = null;
EditorGUILayout.LabelField("Name can't be empty");
disabled = true;
}
else
if (ChartEditorCommon.IsAlphaNum(mValue) == false)
{
mMessage = null;
EditorGUILayout.LabelField("Name contains invalid charecters");
disabled = true;
}
if (mMessage != null)
EditorGUILayout.LabelField(mMessage);
EditorGUILayout.BeginHorizontal();
GUI.enabled = !disabled;
if (GUILayout.Button("Rename"))
{
if (mStartName == mValue)
Close();
else
{
if (mRenameMethod(mStartName,mValue))
Close();
else
mMessage = string.Format("A {0} by the name {1} already exists", mType, mValue);
}
}
GUI.enabled = true;
GUILayout.FlexibleSpace();
if (GUILayout.Button("Cancel"))
Close();
EditorGUILayout.EndHorizontal();
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 66d4769f533803d49a88420cd97553f9
timeCreated: 1481046854
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 3203417d7436b60468e85cdd312a55cf
folderAsset: yes
timeCreated: 1559401944
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 32578c1a672aa5c44bdd3d005e4adff1
folderAsset: yes
timeCreated: 1505898578
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,408 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace ChartAndGraph
{
[CustomEditor(typeof(CandleChart), true)]
class CandleChartInspector : Editor
{
bool mCategories = false;
string mCategoryError = null;
string mNewCategoryName = "";
GUIStyle mRedStyle;
GUIStyle mBold;
HashSet<string> mAllNames = new HashSet<string>();
GUIStyle mSplitter;
List<int> mToRemove = new List<int>();
List<int> mToUp = new List<int>();
Dictionary<string, string> mOperations = new Dictionary<string, string>();
ChartDataEditor mWindow;
Texture mSettings;
RenameWindow mRenameWindow = null;
public void OnEnable()
{
mRedStyle = new GUIStyle();
mRedStyle.normal.textColor = Color.red;
mSplitter = new GUIStyle();
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
mSplitter.stretchWidth = true;
mSplitter.margin = new RectOffset(0, 0, 7, 7);
}
public void Splitter()
{
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
if (Event.current.type == EventType.Repaint)
{
Color restoreColor = GUI.color;
GUI.color = new Color(0.5f, 0.5f, 0.5f);
mSplitter.Draw(position, false, false, false, false);
GUI.color = restoreColor;
}
}
private static bool IsAlphaNum(string str)
{
if (string.IsNullOrEmpty(str))
return false;
for (int i = 0; i < str.Length; i++)
{
if (!(char.IsLetter(str[i])) && (!(char.IsNumber(str[i]))) && str[i] != ' ')
return false;
}
return true;
}
private void DoOperations(SerializedProperty items, int size, string type)
{
mToRemove.Clear();
mToUp.Clear();
bool up = false;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
string arg = type + "|" + name;
string res = null;
if (up == true)
{
mToUp.Add(i);
up = false;
}
if (mOperations.TryGetValue(arg, out res))
{
if (res == "remove")
mToRemove.Add(i);
if (res == "up" && i > 0)
mToUp.Add(i);
if (res == "down")
up = true;
mOperations.Remove(arg);
}
}
for (int i = 0; i < mToRemove.Count; i++)
{
items.DeleteArrayElementAtIndex(mToRemove[i]);
}
for (int i = 0; i < mToUp.Count; i++)
{
int cur = mToUp[i];
items.MoveArrayElement(cur, cur - 1);
}
}
private void CandleSettings(SerializedProperty item)
{
SerializedProperty entry = item.Copy();
EditorGUILayout.LabelField(entry.name);
EditorGUI.indentLevel++;
SerializedProperty end = entry.GetEndProperty(true);
entry.Next(true);
if (SerializedProperty.EqualContents(entry, end) == false)
{
do
{
if (target is CandleChart) // canvas graph chart
{
if ((entry.name == "CandlePrefab"))
{
continue;
}
}
else
{
if (entry.name == "CandleHoverPrefab")
continue;
}
EditorGUILayout.PropertyField(entry, true);
}
while (entry.Next(false) && SerializedProperty.EqualContents(entry, end) == false);
}
EditorGUI.indentLevel--;
}
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
{
SerializedProperty items = data.FindPropertyRelative(property);
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
//bool up, down;
mAllNames.Clear();
int size = items.arraySize;
if (Event.current.type == EventType.Layout)
DoOperations(items, size, type);
size = items.arraySize;
if (items.isExpanded)
{
EditorGUI.indentLevel++;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
mAllNames.Add(name);
bool toogle = false;
EditorGUILayout.BeginHorizontal();
if (nameProp != null)
toogle = entry.isExpanded = EditorGUILayout.Foldout(entry.isExpanded, name);
else
{
toogle = false;
EditorGUILayout.LabelField(name);
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("..."))
DoContext(type, name);
EditorGUILayout.EndHorizontal();
if (toogle)
{
EditorGUI.indentLevel++;
if (nameProp != null)
{
SerializedProperty end = entry.GetEndProperty(true);
entry.Next(true);
if (SerializedProperty.EqualContents(entry, end) == false)
{
do
{
if (entry.name != "Name" && entry.name != "Data")
{
if (target is CandleChart) // canvas graph chart
{
if ((entry.name == "LinePrefab") || (entry.name == "FillPrefab") || (entry.name == "DotPrefab") || (entry.name == "Depth"))
{
continue;
}
}
else
{
if ((entry.name == "LineHoverPrefab") || (entry.name == "PointHoverPrefab"))
continue;
}
if (entry.name == "UpCandle" || entry.name == "DownCandle")
CandleSettings(entry);
else
EditorGUILayout.PropertyField(entry, true);
}
}
while (entry.Next(false) && SerializedProperty.EqualContents(entry, end) == false);
}
}
EditorGUI.indentLevel--;
}
}
if (errorMessage != null)
EditorGUILayout.LabelField(errorMessage, mRedStyle);
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
EditorGUILayout.BeginHorizontal();
newName = EditorGUILayout.TextField(newName);
//GUILayout.Space(indentAdd.xMin);
if (GUILayout.Button("Add"))
{
bool error = false;
if (newName.Trim().Length == 0)
{
errorMessage = "Name can't be empty";
error = true;
}
else if (IsAlphaNum(newName) == false)
{
errorMessage = "Name conatins invalid characters";
error = true;
}
else if (mAllNames.Contains(newName))
{
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
error = true;
}
if (error == false)
{
errorMessage = null;
items.InsertArrayElementAtIndex(size);
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
if (newItemName == null)
newItem.stringValue = newName;
else
newItemName.stringValue = newName;
newName = "";
UpdateWindow();
}
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
else
{
errorMessage = null;
}
UpdateWindow();
}
void callback(object val)
{
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
mOperations[pair.Key] = pair.Value;
}
bool RenameCategory(string oldName, string newName)
{
CandleChart graph = (CandleChart)serializedObject.targetObject;
try
{
graph.DataSource.RenameCategory(oldName, newName);
}
catch (Exception)
{
return false;
}
serializedObject.Update();
if (graph.gameObject.activeInHierarchy)
graph.GenerateChart();
else
EditorUtility.SetDirty(graph);
return true;
}
void RenameCalled(object val)
{
var data = (KeyValuePair<string, string>)val;
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
mRenameWindow = window;
window.ShowDialog(data.Value, data.Key, RenameCategory);
}
void DoContext(string type, string name)
{
string arg = type + "|" + name;
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Move Up"), false, callback, new KeyValuePair<string, string>(arg, "up"));
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
menu.ShowAsContext();
}
void UpdateWindow()
{
}
void OnDisable()
{
if (mRenameWindow != null)
{
mRenameWindow.Close();
mRenameWindow = null;
}
if (mWindow != null)
{
mWindow.Close();
mWindow = null;
}
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
SerializedProperty autoScrollHorizontally = serializedObject.FindProperty("autoScrollHorizontally");
SerializedProperty horizontalScrolling = serializedObject.FindProperty("horizontalScrolling");
SerializedProperty autoScrollVertically = serializedObject.FindProperty("autoScrollVertically");
SerializedProperty verticalScrolling = serializedObject.FindProperty("verticalScrolling");
// SerializedProperty scrollable = serializedObject.FindProperty("scrollable");
// EditorGUILayout.PropertyField(scrollable);
// if (scrollable.boolValue == true)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(autoScrollHorizontally);
if (autoScrollHorizontally.boolValue == false)
EditorGUILayout.PropertyField(horizontalScrolling);
EditorGUILayout.PropertyField(autoScrollVertically);
if (autoScrollVertically.boolValue == false)
EditorGUILayout.PropertyField(verticalScrolling);
EditorGUI.indentLevel--;
}
SerializedProperty graphData = serializedObject.FindProperty("Data");
EditorGUILayout.BeginVertical();
Splitter();
if (mBold == null)
mBold = new GUIStyle(EditorStyles.foldout);
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
NamedItemEditor(graphData, "category", "mSerializedData", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
EditorGUI.indentLevel--;
SerializedProperty horizontalOrigin = graphData.FindPropertyRelative("horizontalViewOrigin");
SerializedProperty horizontalSize = graphData.FindPropertyRelative("horizontalViewSize");
SerializedProperty automaticcHorizontaViewGap = graphData.FindPropertyRelative("automaticcHorizontaViewGap");
SerializedProperty verticalOrigin = graphData.FindPropertyRelative("verticalViewOrigin");
SerializedProperty verticalSize = graphData.FindPropertyRelative("verticalViewSize");
SerializedProperty automaticVerticalViewGap = graphData.FindPropertyRelative("automaticVerticalViewGap");
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Horizontal View", EditorStyles.boldLabel);
SerializedProperty automaticProp = graphData.FindPropertyRelative("automaticHorizontalView");
bool automatic = automaticProp.boolValue;
automatic = GUILayout.Toggle(automatic, "Auto");
GUILayout.FlexibleSpace();
automaticProp.boolValue = automatic;
EditorGUILayout.EndHorizontal();
if (automatic == false)
{
EditorGUILayout.PropertyField(horizontalOrigin);
EditorGUILayout.PropertyField(horizontalSize);
// if (horizontalSize.doubleValue < 0.0)
// horizontalSize.doubleValue = 0.0001;
}
else
{
EditorGUILayout.PropertyField(automaticcHorizontaViewGap, new GUIContent("Horizontal Gap"));
}
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Vertical View", EditorStyles.boldLabel);
automaticProp = graphData.FindPropertyRelative("automaticVerticallView");
automatic = automaticProp.boolValue;
automatic = GUILayout.Toggle(automatic, "Auto");
GUILayout.FlexibleSpace();
automaticProp.boolValue = automatic;
EditorGUILayout.EndHorizontal();
if (automatic == false)
{
EditorGUILayout.PropertyField(verticalOrigin);
EditorGUILayout.PropertyField(verticalSize);
// if (verticalSize.doubleValue < 0.0)
// verticalSize.doubleValue = 0.0001;
}
else
{
EditorGUILayout.PropertyField(automaticVerticalViewGap, new GUIContent("Vertical Gap"));
}
EditorGUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
serializedObject.Update();
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: e95afd72773c44d4ab4ccd60a38ac39e
timeCreated: 1504187754
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,328 +0,0 @@
#define Graph_And_Chart_PRO
using ChartAndGraph;
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(PyramidChart), true)]
class PyramidChartInspetor : Editor
{
bool mCategories = false;
string mCategoryError = null;
string mNewCategoryName = "";
GUIStyle mRedStyle;
GUIStyle mBold;
HashSet<string> mAllNames = new HashSet<string>();
GUIStyle mSplitter;
List<int> mToRemove = new List<int>();
List<int> mToUp = new List<int>();
Dictionary<string, string> mOperations = new Dictionary<string, string>();
ChartDataEditor mWindow;
bool mUpdateWindow = false;
Texture mSettings;
RenameWindow mRenameWindow = null;
public void OnEnable()
{
mRedStyle = new GUIStyle();
mRedStyle.normal.textColor = Color.red;
mSplitter = new GUIStyle();
mSplitter.normal.background = EditorGUIUtility.whiteTexture;
mSplitter.stretchWidth = true;
mSplitter.margin = new RectOffset(0, 0, 7, 7);
}
public void Splitter()
{
Rect position = GUILayoutUtility.GetRect(GUIContent.none, mSplitter, GUILayout.Height(1f));
if (Event.current.type == EventType.Repaint)
{
Color restoreColor = GUI.color;
GUI.color = new Color(0.5f, 0.5f, 0.5f);
mSplitter.Draw(position, false, false, false, false);
GUI.color = restoreColor;
}
}
private static bool IsAlphaNum(string str)
{
if (string.IsNullOrEmpty(str))
return false;
for (int i = 0; i < str.Length; i++)
{
if (!(char.IsLetter(str[i])) && (!(char.IsNumber(str[i]))) && str[i] != ' ')
return false;
}
return true;
}
private void DoOperations(SerializedProperty items, int size, string type)
{
mToRemove.Clear();
mToUp.Clear();
bool up = false;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
string arg = type + "|" + name;
string res = null;
if (up == true)
{
mToUp.Add(i);
up = false;
}
if (mOperations.TryGetValue(arg, out res))
{
if (res == "remove")
mToRemove.Add(i);
if (res == "up" && i > 0)
mToUp.Add(i);
if (res == "down")
up = true;
mOperations.Remove(arg);
}
}
for (int i = 0; i < mToRemove.Count; i++)
items.DeleteArrayElementAtIndex(mToRemove[i]);
for (int i = 0; i < mToUp.Count; i++)
{
int cur = mToUp[i];
items.MoveArrayElement(cur, cur - 1);
}
}
private SerializedProperty getArrayCategory(SerializedProperty arr, string name)
{
for (int i = 0; i < arr.arraySize; i++)
{
SerializedProperty prop = arr.GetArrayElementAtIndex(i);
if (prop.FindPropertyRelative("ColumnName").stringValue == name)
return prop.FindPropertyRelative("Amount");
}
return null;
}
private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
{
SerializedProperty items = data.FindPropertyRelative(property);
SerializedProperty dataValues = data.FindPropertyRelative("mData");
items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
//bool up, down;
mAllNames.Clear();
int size = items.arraySize;
if (Event.current.type == EventType.Layout)
DoOperations(items, size, type);
size = items.arraySize;
if (items.isExpanded)
{
EditorGUI.indentLevel++;
for (int i = 0; i < size; i++)
{
SerializedProperty entry = items.GetArrayElementAtIndex(i);
if (entry == null)
continue;
SerializedProperty nameProp = entry.FindPropertyRelative("Name");
string name = null;
if (nameProp == null)
name = entry.stringValue;
else
name = nameProp.stringValue;
mAllNames.Add(name);
bool toogle = false;
EditorGUILayout.BeginHorizontal();
if (nameProp != null)
toogle = entry.isExpanded =EditorGUILayout.Foldout(entry.isExpanded, name);
else
{
toogle = false;
EditorGUILayout.LabelField(name);
}
SerializedProperty valueProp = getArrayCategory(dataValues, name);
GUILayout.FlexibleSpace();
// if(valueProp != null)
// EditorGUILayout.PropertyField(valueProp);
if (GUILayout.Button("..."))
DoContext(type, name);
EditorGUILayout.EndHorizontal();
if (toogle)
{
EditorGUI.indentLevel++;
if (nameProp != null)
{
SerializedProperty end = entry.GetEndProperty(true);
entry.Next(true);
if (SerializedProperty.EqualContents(entry, end) == false)
{
do
{
if (entry.name != "Name")
EditorGUILayout.PropertyField(entry, true);
if (entry.name == "HeightRatio" && valueProp != null)
valueProp.floatValue = entry.floatValue;
}
while (entry.Next(entry.name == "Materials") && SerializedProperty.EqualContents(entry, end) == false);
}
}
EditorGUI.indentLevel--;
}
}
if (errorMessage != null)
EditorGUILayout.LabelField(errorMessage, mRedStyle);
EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
//Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
EditorGUILayout.BeginHorizontal();
newName = EditorGUILayout.TextField(newName);
//GUILayout.Space(indentAdd.xMin);
if (GUILayout.Button("Add"))
{
bool error = false;
if (newName.Trim().Length == 0)
{
errorMessage = "Name can't be empty";
error = true;
}
else if (IsAlphaNum(newName) == false)
{
errorMessage = "Name conatins invalid characters";
error = true;
}
else if (mAllNames.Contains(newName))
{
errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
error = true;
}
if (error == false)
{
errorMessage = null;
items.InsertArrayElementAtIndex(size);
SerializedProperty newItem = items.GetArrayElementAtIndex(size);
SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
if (newItemName == null)
newItem.stringValue = newName;
else
newItemName.stringValue = newName;
newName = "";
UpdateWindow();
}
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
else
{
errorMessage = null;
}
UpdateWindow();
}
void callback(object val)
{
KeyValuePair<string, string> pair = (KeyValuePair<string, string>)val;
mOperations[pair.Key] = pair.Value;
}
bool RenameCategory(string fromName, string toName)
{
PyramidChart pyramidChart = (PyramidChart)serializedObject.targetObject;
try
{
pyramidChart.DataSource.RenameCategory(fromName, toName);
}
catch (Exception)
{
return false;
}
serializedObject.Update();
if (pyramidChart.gameObject.activeInHierarchy)
pyramidChart.GenerateChart();
else
EditorUtility.SetDirty(pyramidChart);
return true;
}
void RenameCalled(object val)
{
var data = (KeyValuePair<string, string>)val;
RenameWindow window = EditorWindow.GetWindow<RenameWindow>();
mRenameWindow = window;
if (data.Key == "category")
window.ShowDialog(data.Value, data.Key, RenameCategory);
}
void DoContext(string type, string name)
{
string arg = type + "|" + name;
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Move Up"), false, callback, new KeyValuePair<string, string>(arg, "up"));
menu.AddItem(new GUIContent("Move Down"), false, callback, new KeyValuePair<string, string>(arg, "down"));
menu.AddItem(new GUIContent("Remove"), false, callback, new KeyValuePair<string, string>(arg, "remove"));
menu.AddItem(new GUIContent("Rename.."), false, RenameCalled, new KeyValuePair<string, string>(type, name));
menu.ShowAsContext();
}
void UpdateWindow()
{
mUpdateWindow = true;
}
void OnDisable()
{
if(mRenameWindow != null)
{
mRenameWindow.Close();
mRenameWindow = null;
}
if (mWindow != null)
{
mWindow.Close();
mWindow = null;
}
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
SerializedProperty barData = serializedObject.FindProperty("Data");
EditorGUILayout.BeginVertical();
Splitter();
if (mBold == null)
mBold = new GUIStyle(EditorStyles.foldout);
EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
NamedItemEditor(barData, "category", "mCategories", "Categories", ref mCategoryError, ref mCategories, ref mNewCategoryName);
EditorGUI.indentLevel--;
EditorGUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
serializedObject.Update();
if (mUpdateWindow == true)
{
mUpdateWindow = false;
if (mWindow != null)
{
mWindow.SetEditedObject(serializedObject);
mWindow.Repaint();
}
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 79e4c0b8020ab4a42a6d990ae8dc88c3
timeCreated: 1579446121
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 30e0bcb506988d7498bdbaa0867abcf1
folderAsset: yes
timeCreated: 1578946274
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,14 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ChartAndGraph
{
interface IInternalPyramidData
{
ChartSparseDataSource InternalDataSource { get; }
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 369d1c0e7b4b9fc498252bc1ed05b04c
timeCreated: 1579445919
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,21 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace ChartAndGraph
{
public interface IPyramidGenerator
{
GameObject ContainerObject { get; }
void SetParams(float baseX1, float baseX2, float baseSize, float slopLeft, float slopeRight, float height,float inset,float startV,float endV);
Vector3 GetTextPosition(PyramidChart.JustificationType justification,bool isBase);
void GetUpperBase(out float baseX1, out float baseX2);
void Generate();
void ApplyInfo(string title, string text, Sprite image, float scale);
void SetAlpha(float alpha);
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 2a1189b51e201054181a7018cd594f6c
timeCreated: 1579168376
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,42 +0,0 @@
#define Graph_And_Chart_PRO
using UnityEngine;
using System.Collections;
using ChartAndGraph;
public class PyramidAnimation : MonoBehaviour {
public AnimationCurve Curve = AnimationCurve.Linear(0f, 0f, 1f, 1f);
public bool AnimateOnStart = true;
public float AnimationTime = 3f;
float animationStart = -1f;
PyramidChart chart;
// Use this for initialization
void Start () {
chart = GetComponent<PyramidChart>();
if (AnimateOnStart)
Animate();
}
public void Animate()
{
animationStart = Time.time;
}
// Update is called once per frame
void Update ()
{
if (chart == null)
return;
if (animationStart < 0f)
return;
float elasped = (Time.time - animationStart) / AnimationTime;
elasped = Mathf.Clamp(elasped, 0f, 1f);
float blend = Curve.Evaluate(elasped);
for(int i=0; i<chart.DataSource.TotalCategories; i++)
{
string name = chart.DataSource.GetCategoryName(i);
chart.DataSource.SetCategoryAlpha(name, blend);
chart.DataSource.SetCategoryOrientation(name, blend, 0f, 0f);
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 3f8e5b63d2caba14993994657aeb9d90
timeCreated: 1579516412
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,202 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
namespace ChartAndGraph
{
[Serializable]
public class PyramidCanvasGenerator : MaskableGraphic, IPyramidGenerator
{
public RectTransform Container;
public Text Title;
public Text Info;
public Image Sprite;
bool mPopulated = false;
float mBaseX1;
float mBaseX2;
float mBaseSize;
float mSlopLeft;
float mSlopeRight;
float mHeight;
float mInset;
float mStartV;
float mEndV;
CanvasGroup mGroup;
UIVertex[] vertices = new UIVertex[4];
Vector2[] normals = new Vector2[4];
protected override void Start()
{
base.Start();
mGroup = ChartCommon.EnsureComponent<CanvasGroup>(gameObject);
}
public GameObject ContainerObject {
get {
if (Container == null)
return null;
return Container.gameObject;
}
}
public void SetAlpha(float alpha)
{
if(mGroup != null)
mGroup.alpha = alpha;
}
public override Texture mainTexture
{
get { return material.mainTexture; }
}
public void ApplyInfo(string title, string text, Sprite image,float scale)
{
if(Container != null)
{
Vector3 centtroid = vertices[0].position + vertices[1].position + vertices[2].position + vertices[3].position;
centtroid *= 0.25f;
float upperSize = Math.Abs(vertices[2].position.x - vertices[3].position.x);
float downSize = Math.Abs(vertices[0].position.x - vertices[1].position.x);
float total = upperSize + downSize;
float weight = (downSize - upperSize) / total;
weight = -weight * 0.5f + 0.5f;
weight = Mathf.Lerp(0.3f, 0.7f, weight);
centtroid.y = Mathf.Lerp(vertices[0].position.y, vertices[2].position.y, weight);
centtroid = new Vector3(centtroid.x / rectTransform.rect.width, centtroid.y / rectTransform.rect.height);
centtroid += new Vector3(0.5f, 0.5f, 0f);
Container.anchorMax = centtroid;
Container.anchorMin = centtroid;
Container.anchoredPosition = new Vector2();
Container.sizeDelta = new Vector2(Mathf.Abs(mBaseX1 - mBaseX2) - mInset*4, mHeight - mInset*2);
Container.localScale = new Vector3(scale, scale, scale);
}
if (Title != null)
Title.text = title;
if (Info != null)
Info.text = text;
if (Sprite != null)
Sprite.sprite = image;
}
public void Generate()
{
SetAllDirty();
Rebuild(CanvasUpdate.PreRender);
}
public Vector3 GetTextPosition(PyramidChart.JustificationType justification, bool isBase)
{
Vector3 res = new Vector3();
switch(justification)
{
case PyramidChart.JustificationType.LeftAligned:
if (isBase)
res = vertices[0].position;
else
res = (vertices[0].position + vertices[2].position) * 0.5f;
break;
case PyramidChart.JustificationType.RightAligned:
if (isBase)
res = vertices[1].position;
else
res = (vertices[1].position + vertices[3].position) * 0.5f;
break;
case PyramidChart.JustificationType.CenterAligned:
if (isBase)
res = (vertices[0].position + vertices[1].position) * 0.5f;
else
res = (vertices[0].position + vertices[1].position +vertices[2].position + vertices[3].position) * 0.25f;
break;
}
return res;
}
public void GetUpperBase(out float baseX1, out float baseX2)
{
baseX1 = vertices[2].position.x + mBaseSize * 0.5f;
baseX2 = vertices[3].position.x + mBaseSize * 0.5f;
}
public void SetParams(float baseX1, float baseX2, float baseSize, float slopLeft, float slopeRight, float height, float inset, float startV, float endV)
{
mPopulated = true;
mBaseX1 = baseX1;
mBaseX2 = baseX2;
mBaseSize = baseSize;
mSlopLeft = slopLeft;
mSlopeRight = slopeRight;
mHeight = height;
mInset = inset;
mStartV = startV;
mEndV = endV;
PyramidMesh.Generate2dMesh(vertices, normals, mBaseX1, mBaseX2, mBaseSize, mSlopLeft, mSlopeRight, mHeight,mStartV,mEndV);
}
#pragma warning disable 0672
protected override void OnFillVBO(List<UIVertex> vbo)
{
vbo.Clear();
if (mPopulated == false)
return;
CanvasChartMesh mesh = new CanvasChartMesh(vbo);
FillChartMesh(mesh);
}
#pragma warning restore 0672
#if (!UNITY_5_2_0) && (!UNITY_5_2_1)
protected override void OnPopulateMesh(VertexHelper vh)
{
vh.Clear();
if (mPopulated == false)
return;
CanvasChartMesh mesh = new CanvasChartMesh(vh);
FillChartMesh(mesh);
}
#endif
#pragma warning disable 0672
#if !UNITY_2017_1_OR_NEWER
protected override void OnPopulateMesh(Mesh m)
{
m.Clear();
if (mPopulated == false)
return;
WorldSpaceChartMesh chartmesh = new WorldSpaceChartMesh(true);
FillChartMesh(chartmesh);
chartmesh.ApplyToMesh(m);
}
#endif
#pragma warning restore 0672
void FillChartMesh(IChartMesh mesh)
{
UIVertex v1 = vertices[0];
UIVertex v2 = vertices[1];
UIVertex v3 = vertices[2];
UIVertex v4 = vertices[3];
v1.position += (Vector3)(normals[0] * mInset);
v2.position += (Vector3)(normals[1] * mInset);
v3.position += (Vector3)(normals[2] * mInset);
v4.position += (Vector3)(normals[3] * mInset);
Vector2 inter;
if(ChartCommon.SegmentIntersection(v1.position,v3.position,v2.position,v4.position,out inter))
{
v3.position = inter;
v4.position = inter;
}
mesh.AddQuad(v1, v2, v3, v4);
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 7b2cb334c0c0a6448971702fcddbfecd
timeCreated: 1579182822
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,639 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace ChartAndGraph
{
/// <summary>
/// Pie chart class
/// </summary>
[ExecuteInEditMode]
[Serializable]
public class PyramidChart : AnyChart
{
public class PyramidEventArgs
{
public PyramidEventArgs(string category, string title,string text)
{
Title = title;
Text = text;
Category = category;
}
public string Category { get; private set; }
public string Title { get; private set; }
public string Text { get; private set; }
}
public enum JustificationType
{
LeftAligned,
RightAligned,
CenterAligned
}
public enum SlopeType
{
Center,
Left,
Right,
Custom
}
bool mQuick = false;
[Serializable]
public class PyramidEvent : UnityEvent<PyramidEventArgs>
{
}
/// <summary>
/// occures when a pie item is clicked
/// </summary>
public PyramidEvent ItemClicked = new PyramidEvent();
/// <summary>
/// occures when a pie item is hovered
/// </summary>
public PyramidEvent ItemHovered = new PyramidEvent();
/// <summary>
/// occurs when no pie is hovered any longer
/// </summary>
public UnityEvent NonHovered = new UnityEvent();
[SerializeField]
[Tooltip("The material of the back of the pyramid")]
public Material backMaterial;
/// <summary>
/// The inset of each pyramid component
/// </summary>
public Material BackMaterial
{
get { return backMaterial; }
set
{
backMaterial = value;
OnPropertyUpdated();
}
}
[SerializeField]
[Tooltip("The inset of each pyramid component")]
public float inset;
/// <summary>
/// The inset of each pyramid component
/// </summary>
public float Inset
{
get { return inset; }
set
{
inset = value;
OnPropertyUpdated();
}
}
[SerializeField]
[Tooltip("the text justification of the pyramid chart")]
private JustificationType justification;
/// <summary>
/// the text justification of the pyramid chart
/// </summary>
public JustificationType Justification
{
get { return justification; }
set
{
justification = value;
OnPropertyUpdated();
}
}
[SerializeField]
[Tooltip("the slope type of the pyramid")]
public SlopeType slope;
/// <summary>
/// prefab for the pie item. must contain a PieCanvasGenerator component
/// </summary>
public SlopeType Slope
{
get { return slope; }
set
{
slope = value;
OnPropertyUpdated();
}
}
[SerializeField]
[Tooltip("prefab for the pyramid item. must contain a PyramidCanvasGenerator component")]
private PyramidCanvasGenerator prefab;
/// <summary>
/// prefab for the pie item. must contain a PieCanvasGenerator component
/// </summary>
public PyramidCanvasGenerator Prefab
{
get { return prefab; }
set
{
prefab = value;
OnPropertyUpdated();
}
}
[HideInInspector]
[SerializeField]
private PyramidData Data = new PyramidData();
float totalWidth, totalHeight;
protected override IChartData DataLink
{
get
{
return Data;
}
}
public PyramidData DataSource
{
get { return Data; }
}
public override bool SupportRealtimeGeneration
{
get
{
return false;
}
}
protected override LegenedData LegendInfo
{
get
{
LegenedData legend = new LegenedData();
if (Data == null)
return legend;
foreach (var column in ((IInternalPyramidData)Data).InternalDataSource.Columns)
{
var item = new LegenedData.LegenedItem();
item.Name = column.Name;
if (column.Material != null)
item.Material = column.Material.Normal;
else
item.Material = null;
legend.AddLegenedItem(item);
}
return legend;
}
}
public PyramidChart()
{
}
public class PyramidObject
{
public string category;
public GameObject pyramidObject;
public GameObject backObject;
public IPyramidGenerator Generator;
public IPyramidGenerator BackGenerator;
public string Title, Text;
public BillboardText ItemLabel;
}
Dictionary<string, PyramidObject> mPyramids = new Dictionary<string, PyramidObject>();
void HookEvents()
{
Data.ProperyUpdated -= Data_ProperyUpdated;
Data.ProperyUpdated += Data_ProperyUpdated;
Data.RealtimeProperyUpdated -= Data_RealtimeProperyUpdated;
Data.RealtimeProperyUpdated += Data_RealtimeProperyUpdated;
((IInternalPyramidData)Data).InternalDataSource.DataStructureChanged -= MDataSource_DataStructureChanged;
((IInternalPyramidData)Data).InternalDataSource.DataStructureChanged += MDataSource_DataStructureChanged;
((IInternalPyramidData)Data).InternalDataSource.DataValueChanged -= MDataSource_DataValueChanged;
((IInternalPyramidData)Data).InternalDataSource.DataValueChanged += MDataSource_DataValueChanged;
}
private void Data_RealtimeProperyUpdated()
{
QuickInvalidate();
}
private void Data_ProperyUpdated()
{
Invalidate();
}
protected void QuickInvalidate()
{
if (Invalidating)
return;
Invalidate();
mQuick = true;
}
public override void Invalidate()
{
base.Invalidate();
mQuick = false;
}
private void MDataSource_DataValueChanged(object sender, DataSource.ChartDataSourceBase.DataValueChangedEventArgs e)
{
QuickInvalidate();
}
private void MDataSource_DataStructureChanged(object sender, EventArgs e)
{
Invalidate();
}
protected override void Start()
{
base.Start();
if (ChartCommon.IsInEditMode == false)
{
HookEvents();
}
Invalidate();
}
protected override void OnValidate()
{
base.OnValidate();
if (Application.isPlaying)
{
HookEvents();
}
Invalidate();
}
protected override void ClearChart()
{
base.ClearChart();
mPyramids.Clear();
}
Vector3 AlignTextPosition(AlignedItemLabels labels, PyramidObject obj, IPyramidGenerator generator,float height)
{
Vector3 position = new Vector3(labels.Location.Breadth, labels.Seperation, labels.Location.Depth);
position.y += height;
position = generator.GetTextPosition(justification, labels.Alignment == ChartLabelAlignment.Base);
return position;
}
protected IPyramidGenerator PreparePyramidObject(out GameObject pyramidObject)
{
if (Prefab == null)
pyramidObject = new GameObject();
else
pyramidObject = GameObject.Instantiate(Prefab.gameObject);
ChartCommon.EnsureComponent<RectTransform>(pyramidObject);
ChartCommon.EnsureComponent<CanvasRenderer>(pyramidObject);
return ChartCommon.EnsureComponent<PyramidCanvasGenerator>(pyramidObject);
}
private void GeneratePyramid(bool update)
{
if (update == false)
ClearChart();
else
EnsureTextController();
if (((IInternalPyramidData)Data).InternalDataSource == null)
return;
double[,] data = ((IInternalPyramidData)Data).InternalDataSource.getRawData();
int rowCount = data.GetLength(0);
int columnCount = data.GetLength(1);
if (rowCount != 1) // row count for pie must be 1
return;
double total = 0.0;
for (int i = 0; i < columnCount; ++i)
{
double val = Math.Max(data[0, i], 0);
total += val;
}
var rectTrans = GetComponent<RectTransform>();
totalHeight = rectTrans.rect.height;
totalWidth = rectTrans.rect.width;
float baseX1 = 0;
float baseX2 = totalWidth;
float accumilatedHeight = 0;
float? firstCenterHeight = null;
float acummilatedWeight = 0;
for (int i = 0; i < columnCount; ++i)
{
object userData = ((IInternalPyramidData)Data).InternalDataSource.Columns[i].UserData;
var categoryData = ((PyramidData.CategoryData)userData);
string name = ((IInternalPyramidData)Data).InternalDataSource.Columns[i].Name;
double amount = Math.Max(data[0, i], 0);
if (amount == 0f)
continue;
float weight = (float)(amount / total);
float actualHeight = totalHeight * weight;
float slopeRight = categoryData.RightSlope;
float slopeLeft = categoryData.LeftSlope;
float atan;
switch(slope)
{
case SlopeType.Center:
atan = -Mathf.Atan2(totalHeight, totalWidth * 0.5f) * Mathf.Rad2Deg +90;
slopeRight = atan;
slopeLeft = atan;
break;
case SlopeType.Left:
atan = -Mathf.Atan2(totalHeight, totalWidth) * Mathf.Rad2Deg + 90;
slopeLeft = 0;
slopeRight = atan;
break;
case SlopeType.Right:
atan = -Mathf.Atan2(totalHeight, totalWidth) * Mathf.Rad2Deg + 90;
slopeLeft = atan;
slopeRight = 0;
break;
default:
break;
}
GameObject pyramidObject = null;
GameObject pyramidBackObject = null;
IPyramidGenerator generator = null;
IPyramidGenerator backgenerator = null;
PyramidObject dataObject;
float centerHeight = actualHeight * 0.5f + accumilatedHeight;
float unblendedHeight = centerHeight;
if (firstCenterHeight.HasValue == false)
firstCenterHeight = centerHeight;
centerHeight = Mathf.Lerp(firstCenterHeight.Value, centerHeight, categoryData.PositionBlend);
if (mPyramids.TryGetValue(name, out dataObject))
{
pyramidBackObject = dataObject.backObject;
pyramidObject = dataObject.pyramidObject;
backgenerator = dataObject.BackGenerator;
generator = dataObject.Generator;
generator.SetParams(baseX1, baseX2, totalWidth, slopeLeft, slopeRight, actualHeight,inset,0f,1f);
if (backgenerator !=null)
backgenerator.SetParams(baseX1, baseX2, totalWidth, slopeLeft, slopeRight, actualHeight, 0f, acummilatedWeight, acummilatedWeight + weight);
if (dataObject.ItemLabel)
{
Vector3 labelPos = AlignTextPosition(mItemLabels, dataObject,generator, centerHeight);
dataObject.ItemLabel.transform.localPosition = labelPos;
ChartCommon.UpdateTextParams(dataObject.ItemLabel.UIText, categoryData.Title);
}
}
else
{
dataObject = new PyramidObject();
if (backMaterial != null)
{
var backGenerator = PreparePyramidObject(out pyramidBackObject);
backGenerator.SetParams(baseX1, baseX2, totalWidth, slopeLeft, slopeRight, actualHeight, 0f, acummilatedWeight, acummilatedWeight +weight);
dataObject.backObject = pyramidBackObject;
dataObject.BackGenerator = backGenerator;
ChartCommon.HideObject(pyramidBackObject, hideHierarchy);
pyramidBackObject.transform.SetParent(transform,false);
ChartCommon.EnsureComponent<ChartItem>(pyramidBackObject);
ChartMaterialController backcontrol = ChartCommon.EnsureComponent<ChartMaterialController>(pyramidBackObject);
backcontrol.Materials = new ChartDynamicMaterial(backMaterial);
foreach(var itemEffect in pyramidBackObject.GetComponents<ChartItemEffect>())
ChartCommon.SafeDestroy(itemEffect);
ChartCommon.SafeDestroy(backGenerator.ContainerObject);
}
generator = PreparePyramidObject(out pyramidObject);
generator.SetParams(baseX1, baseX2, totalWidth, slopeLeft, slopeRight, actualHeight, inset,0f,1f);
ChartCommon.HideObject(pyramidObject, hideHierarchy);
pyramidObject.transform.SetParent(transform,false);
ChartCommon.EnsureComponent<ChartItem>(pyramidObject);
ChartMaterialController control = ChartCommon.EnsureComponent<ChartMaterialController>(pyramidObject);
control.Materials = Data.GetMaterial(name);
control.Refresh();
dataObject.Generator = generator;
dataObject.category = name;
dataObject.pyramidObject = pyramidObject;
mPyramids.Add(name, dataObject);
CharItemEffectController effect = ChartCommon.EnsureComponent<CharItemEffectController>(pyramidObject);
effect.WorkOnParent = false;
effect.InitialScale = false;
ChartItemEvents[] events = pyramidObject.GetComponentsInChildren<ChartItemEvents>();
for (int j = 0; j < events.Length; ++j)
{
if (events[j] == null)
continue;
InternalItemEvents comp = (InternalItemEvents)events[j];
comp.Parent = this;
comp.UserData = dataObject;
}
if (mItemLabels != null)
{
Vector3 labelPos = AlignTextPosition(mItemLabels, dataObject, generator, 0f);
float angle = justification == JustificationType.LeftAligned ? -180f : 180f;
BillboardText billboard = ChartCommon.CreateBillboardText(null, mItemLabels.TextPrefab, dataObject.pyramidObject.transform, categoryData.Title, labelPos.x, labelPos.y, labelPos.z, angle, null, hideHierarchy, mItemLabels.FontSize, mItemLabels.FontSharpness);
dataObject.ItemLabel = billboard;
dataObject.ItemLabel.transform.localPosition = labelPos;
TextController.AddText(billboard);
}
}
dataObject.Text = categoryData.Text;
dataObject.Title = categoryData.Title;
if (IsCanvas)
{
if (pyramidObject != null)
{
Vector2 actualPosition = new Vector2(0.5f, centerHeight) + categoryData.Shift;
actualPosition = new Vector2(actualPosition.x , actualPosition.y / TotalHeight);
var objectRect = pyramidObject.GetComponent<RectTransform>();
objectRect.pivot = new Vector2(0.5f, 0.5f);
objectRect.anchorMin = actualPosition;
objectRect.anchorMax = actualPosition;
objectRect.anchoredPosition = new Vector2();
objectRect.sizeDelta = new Vector2(totalWidth, actualHeight);
}
if(pyramidBackObject != null)
{
Vector2 actualPosition = new Vector2(0.5f, unblendedHeight);
actualPosition = new Vector2(actualPosition.x, actualPosition.y / TotalHeight);
var objectRect = pyramidBackObject.GetComponent<RectTransform>();
objectRect.pivot = new Vector2(0f, 0f);
objectRect.anchorMin = actualPosition;
objectRect.anchorMax = actualPosition;
objectRect.anchoredPosition = new Vector2();
}
}
accumilatedHeight += actualHeight;
acummilatedWeight += weight;
if(backgenerator!= null)
backgenerator.Generate();
generator.Generate();
generator.GetUpperBase(out baseX1, out baseX2);
generator.ApplyInfo(categoryData.Title, categoryData.Text, categoryData.Image,categoryData.Scale);
generator.SetAlpha(categoryData.Alpha);
}
}
protected override void OnLabelSettingChanged()
{
base.OnLabelSettingChanged();
Invalidate();
}
protected override void OnLabelSettingsSet()
{
base.OnLabelSettingsSet();
Invalidate();
}
public override void InternalGenerateChart()
{
if (gameObject.activeInHierarchy == false)
return;
base.InternalGenerateChart();
GeneratePyramid(mQuick);
mQuick = false;
}
protected override bool HasValues(AxisBase axis)
{
return false;
}
protected override double MaxValue(AxisBase axis)
{
return 0.0;
}
protected override double MinValue(AxisBase axis)
{
return 0.0;
}
protected virtual void OnPropertyChanged()
{
QuickInvalidate();
}
protected override void OnPropertyUpdated()
{
base.OnPropertyUpdated();
Invalidate();
}
protected override void ValidateProperties()
{
base.ValidateProperties();
if (inset < 0)
inset = 0;
}
PyramidEventArgs userDataToEventArgs(object userData)
{
PyramidObject pyramid = (PyramidObject)userData;
return new PyramidEventArgs(pyramid.category, pyramid.Title,pyramid.Text);
}
protected override void OnNonHoverted()
{
base.OnNonHoverted();
if (NonHovered != null)
NonHovered.Invoke();
}
protected override void OnItemHoverted(object userData)
{
base.OnItemHoverted(userData);
if (ItemHovered != null)
ItemHovered.Invoke(userDataToEventArgs(userData));
}
protected override void OnItemSelected(object userData)
{
base.OnItemSelected(userData);
var args = userDataToEventArgs(userData);
if (ItemClicked != null)
ItemClicked.Invoke(args);
}
protected override void Update()
{
base.Update();
}
protected override bool SupportsCategoryLabels
{
get
{
return true;
}
}
protected override bool SupportsGroupLables
{
get
{
return false;
}
}
protected override bool SupportsItemLabels
{
get
{
return false;
}
}
protected override bool ShouldFitCanvas { get { return false; } }
protected override float TotalDepthLink { get { return 0f; } }
protected override float TotalHeightLink { get { return totalHeight; } }
protected override float TotalWidthLink { get { return totalWidth; } }
public override bool IsCanvas { get { return true; } }
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 5d0cd7c0544e4cc439d4a030e8a7a470
timeCreated: 1578949498
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,450 +0,0 @@
#define Graph_And_Chart_PRO
using ChartAndGraph.DataSource;
using ChartAndGraph.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace ChartAndGraph
{
[Serializable]
public class PyramidData : AbstractChartData, IInternalPyramidData, IChartData
{
[Serializable]
internal class CategoryData
{
public string Name;
public ChartDynamicMaterial Materials;
public String Title;
public String Text;
public Sprite Image;
public float RightSlope;
public float LeftSlope;
public float HeightRatio;
public float Alpha;
public float Scale;
public float ShiftX, ShiftY;
public float PositionBlend;
public Vector2 Shift { get { return new Vector2(ShiftX, ShiftY); } }
}
[Serializable]
class DataEntry
{
public string GroupName;
public string ColumnName;
public double Amount;
}
public PyramidData()
{
mDataSource = new ChartSparseDataSource();
if (mDataSource.Rows.Count == 0)
mDataSource.Rows.Add(new DataSource.ChartDataRow("Pyramid"));
}
private ChartSparseDataSource mDataSource;
ChartSparseDataSource IInternalPyramidData.InternalDataSource { get { return mDataSource; } }
[SerializeField]
private CategoryData[] mCategories = new CategoryData[0];
[SerializeField]
private string[] mGroups = new string[1] { "Pyramid" };
[SerializeField]
private DataEntry[] mData = new DataEntry[0];
public int TotalCategories { get { return mDataSource.Columns.Count; } }
public void Update()
{
UpdateSliders();
}
public string GetCategoryName(int index)
{
return mDataSource.Columns[index].Name;
}
public void OnBeforeSerialize()
{
int totalColumns = mDataSource.Columns.Count;
mCategories = new CategoryData[totalColumns];
for (int i = 0; i < totalColumns; i++)
{
CategoryData data = new CategoryData();
data.Name = mDataSource.Columns[i].Name;
data.Materials = mDataSource.Columns[i].Material;
object userData = mDataSource.Columns[i].UserData;
if (userData != null && userData is CategoryData)
{
data.Alpha = ((CategoryData)userData).Alpha;
data.HeightRatio = ((CategoryData)userData).HeightRatio;
data.Image = ((CategoryData)userData).Image;
data.Title = ((CategoryData)userData).Title;
data.LeftSlope = ((CategoryData)userData).LeftSlope;
data.RightSlope = ((CategoryData)userData).RightSlope;
data.Scale = ((CategoryData)userData).Scale;
data.ShiftX = ((CategoryData)userData).ShiftX;
data.ShiftY = ((CategoryData)userData).ShiftY;
data.Text = ((CategoryData)userData).Text;
data.PositionBlend = ((CategoryData)userData).PositionBlend;
}
else
{
data.Alpha = 1f;
data.HeightRatio = 1f;
data.Image = null;
data.Title = "";
data.LeftSlope = -0.5f;
data.RightSlope = -0.5f;
data.Scale = 1f;
data.ShiftX = 0f;
data.ShiftY = 0f;
data.Text = ((CategoryData)userData).Text;
data.PositionBlend = 1f;
}
mCategories[i] = data;
}
int totalRows = mDataSource.Rows.Count;
mGroups = new string[totalRows];
for (int i = 0; i < totalRows; i++)
mGroups[i] = mDataSource.Rows[i].Name;
double[,] raw = mDataSource.getRawData();
int current = 0;
mData = new DataEntry[raw.GetLength(0) * raw.GetLength(1)];
for (int i = 0; i < raw.GetLength(0); ++i)
{
for (int j = 0; j < raw.GetLength(1); ++j)
{
DataEntry entry = new DataEntry();
entry.ColumnName = mDataSource.Columns[j].Name;
entry.GroupName = mDataSource.Rows[i].Name;
entry.Amount = raw[i, j];
mData[current++] = entry;
}
}
}
public event Action ProperyUpdated;
public event Action RealtimeProperyUpdated;
protected void RaiseRealtimePropertyUpdated()
{
if (RealtimeProperyUpdated != null)
RealtimeProperyUpdated();
}
protected void RaisePropertyUpdated()
{
if (ProperyUpdated != null)
ProperyUpdated();
}
public bool HasCategory(string category)
{
try
{
var col = mDataSource.Columns[category];
if (col != null)
return true;
}
catch
{
}
return false;
}
/// <summary>
/// rename a category. throws an exception on error
/// </summary>
/// <param name="prevName"></param>
/// <param name="newName"></param>
public void RenameCategory(string prevName, string newName)
{
mDataSource.Columns[prevName].Name = newName;
RaisePropertyUpdated();
}
public object StoreCategory(string category)
{
CategoryData data = (CategoryData)(mDataSource.Columns[category].UserData);
data.Materials = mDataSource.Columns[category].Material;
return data;
}
public void RestoreCategory(string category, object data)
{
var toSet = (CategoryData)data;
CategoryData current = (CategoryData)(mDataSource.Columns[category].UserData);
current.Alpha = ((CategoryData)toSet).Alpha;
current.HeightRatio = ((CategoryData)toSet).HeightRatio;
current.Image = ((CategoryData)toSet).Image;
current.Title = ((CategoryData)toSet).Title;
current.LeftSlope = ((CategoryData)toSet).LeftSlope;
current.RightSlope = ((CategoryData)toSet).RightSlope;
current.Scale = ((CategoryData)toSet).Scale;
current.ShiftX = ((CategoryData)toSet).ShiftX;
current.ShiftY = ((CategoryData)toSet).ShiftY;
current.Text = ((CategoryData)toSet).Text;
current.PositionBlend = ((CategoryData)toSet).PositionBlend;
current.Materials = toSet.Materials;
mDataSource.Columns[category].Material = toSet.Materials;
RaisePropertyUpdated();
}
/// <summary>
/// call this to suspend chart redrawing while updating the data of the chart
/// </summary>
public void StartBatch()
{
mDataSource.SuspendEvents = true;
}
/// <summary>
/// call this after StartBatch , this will apply all the changed made between the StartBatch call to this call
/// </summary>
public void EndBatch()
{
mDataSource.SuspendEvents = false;
}
public void OnAfterDeserialize()
{
mDataSource = new ChartSparseDataSource();
mDataSource.SuspendEvents = true;
mDataSource.Clear();
if (mCategories == null)
mCategories = new CategoryData[0];
if (mGroups == null)
mGroups = new string[0];
if (mData == null)
mData = new DataEntry[0];
for (int i = 0; i < mCategories.Length; i++)
AddCategory(mCategories[i].Name, mCategories[i].Materials, mCategories[i].Title, mCategories[i].Text, mCategories[i].Image, mCategories[i].Alpha, mCategories[i].HeightRatio, mCategories[i].LeftSlope, mCategories[i].RightSlope, mCategories[i].PositionBlend, mCategories[i].Scale, mCategories[i].ShiftX, mCategories[i].ShiftY);
// for (int i = 0; i < mGroups.Length; i++)
// AddGroup(mGroups[i]);
if (mDataSource.Rows.Count == 0)
mDataSource.Rows.Add(new DataSource.ChartDataRow("Pyramid"));
for (int i = 0; i < mData.Length; i++)
{
try
{
DataEntry entry = mData[i];
mDataSource.SetValue(entry.ColumnName, entry.GroupName, entry.Amount);
}
catch (Exception)
{
}
}
mDataSource.SuspendEvents = false;
}
private void AddGroup(string name)
{
mDataSource.Rows.Add(new ChartDataRow(name));
}
/// <summary>
/// Adds a new category to the pyramid chart. Each category has it's own material and name. each category corresponds to one pyr slice
/// </summary>
/// <param name="name">the name of the category</param>
/// <param name="material">the material of the category</param>
public void AddCategory(string name, Material material, String title, String text, Sprite image)
{
AddCategory(name, new ChartDynamicMaterial(material),title,text,image);
}
/// <summary>
/// Adds a new category to the pyramid chart. Each category has it's own material and name. each category corresponds to one pie slice
/// </summary>
/// <param name="name">the name of the category</param>
/// <param name="material">the dynamic material of the category. dynamic materials allows setting the material for different events</param>
public void AddCategory(string name, ChartDynamicMaterial material, String title, String text, Sprite image,float alpha = 1f,float heightRatio = 1f,float leftSlope = 45f,float rightSlope = 45f,float positionBlend = 1f,float scale = 1f, float shiftX = 0f,float shiftY =0f)
{
if (title == null)
title = "";
if (text == null)
text = "";
ChartDataColumn column = new ChartDataColumn(name);
column.Material = material;
CategoryData d = new CategoryData();
d.Title = title;
d.Text = text;
d.Image = image;
d.Alpha = alpha;
d.HeightRatio = heightRatio;
d.LeftSlope = leftSlope;
d.RightSlope = rightSlope;
d.PositionBlend = positionBlend;
d.Scale = scale;
d.ShiftX = shiftX;
d.ShiftY = shiftY;
column.UserData = d;
mDataSource.mColumns.Add(column);
SetValueInternal(name, "Pyramid", heightRatio);
}
public void SetCategoryInfo(string category,string title,string text,Sprite image)
{
if (title == null)
title = "";
if (text == null)
text = "";
var col = mDataSource.Columns[category];
CategoryData data = col.UserData as CategoryData;
data.Text = text;
data.Title = title;
data.Image = image;
RaisePropertyUpdated();
}
public void SetCategoryAlpha(string category, float alpha)
{
var col = mDataSource.Columns[category];
CategoryData data = col.UserData as CategoryData;
data.Alpha = alpha;
RaiseRealtimePropertyUpdated();
}
public void SetCategoryContentScale(string category,float scale)
{
var col = mDataSource.Columns[category];
CategoryData data = col.UserData as CategoryData;
data.Scale = scale;
RaiseRealtimePropertyUpdated();
}
public void SetCategoryOrientation(string category,float positionBlend,float shiftX ,float shiftY)
{
var col = mDataSource.Columns[category];
CategoryData data = col.UserData as CategoryData;
data.PositionBlend = positionBlend;
data.ShiftX = shiftX;
data.ShiftY = shiftY;
RaiseRealtimePropertyUpdated();
}
public void SetCategorySlope(string category,float leftSlop,float rightSlope)
{
var col = mDataSource.Columns[category];
CategoryData data = col.UserData as CategoryData;
data.LeftSlope = leftSlop;
data.RightSlope = rightSlope;
RaiseRealtimePropertyUpdated();
}
public void SetCategoryHeightRatio(string category, float heightRatio)
{
var col = mDataSource.Columns[category];
CategoryData data = col.UserData as CategoryData;
data.HeightRatio = heightRatio;
SetValueInternal(category, "Pyramid", heightRatio);
RaiseRealtimePropertyUpdated();
}
/// <summary>
/// clears the pyramid chart data
/// </summary>
public void Clear()
{
string[] groups = mDataSource.Columns.Select(x => x.Name).ToArray();
foreach (string s in groups)
{
RemoveCategory(s);
}
}
/// <summary>
/// sets the material for the specified category
/// </summary>
/// <param name="category">the name of the category</param>
/// <param name="material">the material of the category</param>
public void SetMaterial(string category, Material material)
{
SetMaterial(category, new ChartDynamicMaterial(material));
}
internal ChartDynamicMaterial GetMaterial(string category)
{
return mDataSource.Columns[category].Material;
}
/// <summary>
/// sets the material for the specified category
/// </summary>
/// <param name="category">the name of the category</param>
/// <param name="material">the dynamic material of the category. dynamic materials allow setting the material for different events</param>
public void SetMaterial(string category, ChartDynamicMaterial material)
{
mDataSource.Columns[category].Material = material;
RaisePropertyUpdated();
}
/// <summary>
/// removes a category from the pyramid chart
/// </summary>
/// <param name="name">the name of the category to remove</param>
public void RemoveCategory(string name)
{
ChartDataColumn column = mDataSource.Columns[name];
RemoveSlider(name, "Pyramid");
mDataSource.Columns.Remove(column);
}
/// <summary>
/// gets the value for the specified category
/// </summary>
/// <param name="category">the category name</param>
/// <param name="group">the group name</param>
/// <returns></returns>
public double GetValue(string category)
{
return mDataSource.GetValue(category, "Pyramid");
}
public bool CheckAnimationEnded(float time, AnimationCurve curve)
{
if (curve.length == 0)
return true;
return time > curve.keys[curve.length - 1].time;
}
/// <summary>
/// used intenally , do not call
/// </summary>
/// <param name="cats"></param>
public object[] StoreAllCategoriesinOrder()
{
return mCategories.ToArray();
}
private void FixEaseFunction(AnimationCurve curve)
{
curve.postWrapMode = WrapMode.Once;
curve.preWrapMode = WrapMode.Once;
}
protected override void SetValueInternal(string column, string row, double value)
{
try
{
if(mDataSource.Rows.Count ==0 )
mDataSource.Rows.Add(new DataSource.ChartDataRow("Pyramid"));
mDataSource.SetValue(column, "Pyramid", value);
}
catch (ChartException e)
{
Debug.LogWarning(e.Message);
}
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 46cd052151826fb41a072a83f913f790
timeCreated: 1578948915
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,47 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace ChartAndGraph
{
class PyramidMesh
{
public static void Generate2dMesh(UIVertex[] mesh, Vector2[] normals,float baseX1, float baseX2,float baseSize, float slopLeft, float slopeRight, float height,float startV,float endV)
{
float halfHeight = height * 0.5f;
float halfWidth = baseSize * 0.5f;
slopLeft = -Mathf.Clamp(slopLeft, -90, 90) +90;
slopeRight = Mathf.Clamp(slopeRight ,- 90, 90) +90;
float tanLeft = (1f/Mathf.Tan(slopLeft * Mathf.Deg2Rad)) * height;
float tanRight =(1f/Mathf.Tan(slopeRight * Mathf.Deg2Rad)) * height;
float leftPos = baseX1 + tanLeft;
float rightPos = baseX2 + tanRight;
leftPos = Mathf.Clamp(leftPos, 0,baseSize);
rightPos = Mathf.Clamp(rightPos, 0, baseSize);
if (leftPos > rightPos)
leftPos = rightPos = Mathf.Clamp(Mathf.Lerp(leftPos, rightPos, 0.5f), 0, baseSize);
UIVertex v1 = ChartCommon.CreateVertex(new Vector3(baseX1 - halfWidth, -halfHeight), new Vector2(0f, startV));
UIVertex v2 = ChartCommon.CreateVertex(new Vector3(baseX2 - halfWidth, -halfHeight), new Vector2(1f, startV));
UIVertex v3 = ChartCommon.CreateVertex(new Vector3(leftPos - halfWidth, halfHeight), new Vector2(0f, endV));
UIVertex v4 = ChartCommon.CreateVertex(new Vector3(rightPos - halfWidth, halfHeight), new Vector2(1f, endV));
normals[0] = ((Vector2.up + ChartCommon.Perpendicular(v3.position - v1.position).normalized) * 0.5f).normalized;
normals[1] = ((Vector2.up + ChartCommon.Perpendicular(v2.position - v4.position).normalized) * 0.5f).normalized;
normals[2] = ((Vector2.down + ChartCommon.Perpendicular(v3.position - v1.position).normalized) * 0.5f).normalized;
normals[3] = ((Vector2.down + ChartCommon.Perpendicular(v2.position - v4.position).normalized) * 0.5f).normalized;
mesh[0] = v1;
mesh[1] = v2;
mesh[2] = v3;
mesh[3] = v4;
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 1cc5bd615b17ae34292624585cda8e6a
timeCreated: 1579182822
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: b321e42897743dd4aa55fd6373025c34
folderAsset: yes
timeCreated: 1505898441
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 1c5df8a40695a4340beca4c338df7e39
folderAsset: yes
timeCreated: 1491152606
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,651 +0,0 @@
#define Graph_And_Chart_PRO
#define CandleChart
using ChartAndGraph;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.Events;
namespace ChartAndGraph
{
[ExecuteInEditMode]
public abstract class CandleChart : ScrollableAxisChart
{
/// <summary>
/// a candle chart event
/// </summary>
[Serializable]
public class CandleEvent : UnityEvent<CandleEventArgs>
{
}
[SerializeField]
[Tooltip("The height ratio of the chart")]
protected float heightRatio = 300;
[SerializeField]
[Tooltip("The width ratio of the chart")]
protected float widthRatio = 600;
protected override float TotalHeightLink
{
get
{
return heightRatio;
}
}
protected override float TotalWidthLink
{
get
{
return widthRatio;
}
}
/// <summary>
/// occures when a point is clicked
/// </summary>
public CandleEvent CandleClicked = new CandleEvent();
/// <summary>
/// occurs when a point is hovered
/// </summary>
public CandleEvent CandleHovered = new CandleEvent();
/// <summary>
/// occurs when no candle is hovered any longer
/// </summary>
public UnityEvent NonHovered = new UnityEvent();
public enum CandleThicknessMode
{
/// <summary>
/// the candle size is detemined only by the candle duration paramenter
/// </summary>
Fill,
/// <summary>
/// the candle is of constant size , regardless of the view size
/// </summary>
Constant,
/// <summary>
/// the candle size is fixed , but proportional to the view size
/// </summary>
Proportional
}
/// <summary>
/// format a candle value to the parameter strings
/// </summary>
/// <param name="candleVal"></param>
/// <param name="fractionDigits"></param>
/// <param name="open"></param>
/// <param name="high"></param>
/// <param name="low"></param>
/// <param name="close"></param>
public void FormatCandleValue(CandleChartData.CandleValue candleVal, int fractionDigits, out string open, out string high, out string low, out string close)
{
open = StringFromAxisFormat(new DoubleVector3(candleVal.Start,candleVal.Open,0.0), mVerticalAxis,false);
close = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Close, 0.0), mVerticalAxis, false);
high = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.High, 0.0), mVerticalAxis, false);
low = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Low, 0.0), mVerticalAxis, false);
}
/// <summary>
/// format a candle value to the parameter strings
/// </summary>
/// <param name="candleVal"></param>
/// <param name="fractionDigits"></param>
/// <param name="start"></param>
/// <param name="duration"></param>
public void FormatCandleValue(CandleChartData.CandleValue candleVal, int fractionDigits, out string start, out string duration)
{
start = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Open, 0.0), mHorizontalAxis, true);
duration = StringFromAxisFormat(new DoubleVector3(candleVal.Duration, candleVal.Open, 0.0), mHorizontalAxis, true);
}
/// <summary>
/// format a candle value to the parameter strings
/// </summary>
/// <param name="candleVal"></param>
/// <param name="fractionDigits"></param>
/// <param name="open"></param>
/// <param name="high"></param>
/// <param name="low"></param>
/// <param name="close"></param>
/// <param name="start"></param>
/// <param name="duration"></param>
public void FormatCandleValue(CandleChartData.CandleValue candleVal, int fractionDigits, out string open, out string high, out string low, out string close, out string start, out string duration)
{
FormatCandleValue(candleVal, fractionDigits, out open, out high, out low, out close);
FormatCandleValue(candleVal, fractionDigits, out start, out duration);
}
public class CandleEventArgs
{
int mType;
public CandleEventArgs(int index, int type, Rect selectionRect, Vector3 position, CandleChartData.CandleValue value, string category)
{
mType = type;
Position = position;
SelectionRect = selectionRect;
CandleValue = value;
Category = category;
}
/// <summary>
/// true if this event is triggered for the high portion of the candle
/// </summary>
public bool IsHighEvent { get { return mType == 0; } }
/// <summary>
/// true if this event is triggered for the low portion of the candle
/// </summary>
public bool IsLowEvent { get { return mType == 2; } }
/// <summary>
/// true if this event is triggerd for the body portion of the candle (open/close)
/// </summary>
public bool IsBodyEvent { get { return mType == 1; } }
/// <summary>
/// the rect on the canvas that represents the selected object
/// </summary>
public Rect SelectionRect { get; private set; }
/// <summary>
/// mouse position
/// </summary>
public Vector3 Position { get; private set; }
/// <summary>
/// the index of the candle in the data
/// </summary>
public int Index { get; private set; }
/// <summary>
/// the value of the candle
/// </summary>
public CandleChartData.CandleValue CandleValue { get; private set; }
/// <summary>
/// the category of the candle
/// </summary>
public string Category { get; private set; }
}
[SerializeField]
[Tooltip("Thickness mode for the candle chart")]
protected CandleThicknessMode thicknessMode = CandleThicknessMode.Constant;
/// <summary>
/// Thickness mode for the candle chart
/// </summary>
public CandleThicknessMode ThicknessMode
{
get { return thicknessMode; }
set
{
thicknessMode = value;
Invalidate();
}
}
protected override IChartData DataLink
{
get
{
return Data;
}
}
[SerializeField]
[Tooltip("Thickness contant for the candle chart , it's meaning depends on the thickness mode")]
protected float thicknessConstant = 10f;
/// <summary>
/// Thickness contant for the candle chart , it's meaning depends on the thickness mode\
/// Fill - multiply the duration size of the candle by a constant , should be between 0f to 1f
/// Constant - the pixel size of the candle
/// Proportional - constant size of the candle in seconds
/// </summary>
public float ThicknessConstant
{
get { return thicknessConstant; }
set
{
thicknessConstant = value;
Invalidate();
}
}
protected override float GetScrollingRange(int axis)
{
float min = (float)((IInternalCandleData)Data).GetMinValue(axis, false);
float max = (float)((IInternalCandleData)Data).GetMaxValue(axis, false);
return max - min;
}
[SerializeField]
[Tooltip("format with the following labels: <?start> , <?duration>,<?open>,<?high>,<?low>,<?close>")]
private string itemFormat = "O:<?open>,H:<?high>,L:<?low>,C:<?close>";
/// <summary>
/// format with the following labels:
/// <?start>
/// <?duration>
/// <?open>
/// <?close>
/// <?high>
/// <?low>
/// </summary>
public string ItemFormat
{
get { return itemFormat; }
set
{
itemFormat = value;
Invalidate();
}
}
[SerializeField]
[Tooltip("Used when using hoverItem component, and the mouse is hovering over the body of the candle,format with the following labels: <?start> , <?duration>,<?open>,<?high>,<?low>,<?close>")]
private string bodyFormat = "O:<?open>,C:<?close>";
/// <summary>
/// format with the following labels:
/// <?start>
/// <?duration>
/// <?open>
/// <?close>
/// <?high>
/// <?low>
/// </summary>
public string BodyFormat
{
get { return bodyFormat; }
set
{
bodyFormat = value;
Invalidate();
}
}
[SerializeField]
[Tooltip("Used when using hoverItem component, and the mouse is hovering over the high line of the candle,format with the following labels: <?start> , <?duration>,<?open>,<?high>,<?low>,<?close>")]
private string highFormat = "H:<?high>";
public string HighFormat
{
get { return highFormat; }
set
{
highFormat = value;
Invalidate();
}
}
[SerializeField]
[Tooltip("Used when using hoverItem component, and the mouse is hovering over the low line of the candle,format with the following labels: <?start> , <?duration>,<?open>,<?high>,<?low>,<?close>")]
private string lowFormat = "L:<?low>";
public string LowFormat
{
get { return lowFormat; }
set
{
lowFormat = value;
Invalidate();
}
}
/// <summary>
/// the candle chart data
/// </summary>
[HideInInspector]
[SerializeField]
protected CandleChartData Data = new CandleChartData();
/// <summary>
/// Holds the candle chart data. including values and categories
/// </summary>
public CandleChartData DataSource { get { return Data; } }
protected override void Start()
{
base.Start();
if (ChartCommon.IsInEditMode == false)
{
HookEvents();
}
Invalidate();
}
protected override void OnValidate()
{
base.OnValidate();
if (ChartCommon.IsInEditMode == false)
{
HookEvents();
}
Data.RestoreDataValues();
Invalidate();
}
/// <summary>
/// hooks data source events.
/// </summary>
protected void HookEvents()
{
((IInternalCandleData)Data).InternalDataChanged -= CandleChart_InternalDataChanged;
((IInternalCandleData)Data).InternalDataChanged += CandleChart_InternalDataChanged;
((IInternalCandleData)Data).InternalViewPortionChanged -= CandleChart_InternalViewPortionChanged;
((IInternalCandleData)Data).InternalViewPortionChanged += CandleChart_InternalViewPortionChanged;
((IInternalCandleData)Data).InternalRealTimeDataChanged -= CandleChart_InternalRealTimeDataChanged;
((IInternalCandleData)Data).InternalRealTimeDataChanged += CandleChart_InternalRealTimeDataChanged;
}
private void CandleChart_InternalViewPortionChanged(object sender, EventArgs e)
{
InvalidateRealtime();
}
private void CandleChart_InternalRealTimeDataChanged(int index,string str)
{
InvalidateRealtime();
}
private void CandleChart_InternalDataChanged(object sender, EventArgs e)
{
Invalidate();
}
protected override void OnLabelSettingChanged()
{
base.OnLabelSettingChanged();
Invalidate();
}
protected override void OnAxisValuesChanged()
{
base.OnAxisValuesChanged();
Invalidate();
}
protected override void OnLabelSettingsSet()
{
base.OnLabelSettingsSet();
Invalidate();
}
protected override LegenedData LegendInfo
{
get
{
LegenedData data = new LegenedData();
if (Data == null)
return data;
foreach (var cat in ((IInternalCandleData)Data).Categories)
{
for (int i = 0; i < 2; i++)
{
LegenedData.LegenedItem item = new LegenedData.LegenedItem();
CandleChartData.CandleSettings settings = cat.UpCandle;
if (i == 0)
{
item.Name = cat.Name + " Increasing";
}
else
{
item.Name = cat.Name + " Decreasing";
settings = cat.DownCandle;
}
if (settings.Fill != null)
item.Material = settings.Fill;
else
{
if (settings.Outline != null)
item.Material = settings.Outline;
else
item.Material = settings.Line;
}
data.AddLegenedItem(item);
}
}
return data;
}
}
protected override bool SupportsCategoryLabels
{
get
{
return true;
}
}
protected override bool SupportsGroupLables
{
get
{
return false;
}
}
protected override bool SupportsItemLabels
{
get
{
return true;
}
}
protected override bool HasValues(AxisBase axis)
{
if (axis == mVerticalAxis || axis == mHorizontalAxis) // has both horizontal and vertical axis
return true;
return false;
}
protected override double MaxValue(AxisBase axis)
{
if (axis == null)
return 0.0;
if (axis == mHorizontalAxis)
return ((IInternalCandleData)Data).GetMaxValue(0, false);
if (axis == mVerticalAxis)
return ((IInternalCandleData)Data).GetMaxValue(1, false);
return 0.0;
}
protected override double MinValue(AxisBase axis)
{
if (axis == null)
return 0.0;
if (axis == mHorizontalAxis)
return ((IInternalCandleData)Data).GetMinValue(0, false);
if (axis == mVerticalAxis)
return ((IInternalCandleData)Data).GetMinValue(1, false);
return 0.0;
}
void Deflate(ref double start, ref double duration, double amount)
{
double center = start + duration * 0.5;
duration *= amount;
start = center - duration * 0.5;
}
CandleChartData.CandleValue NormalizeCandle(CandleChartData.CandleValue candle, DoubleVector3 min, DoubleVector3 range)
{
CandleChartData.CandleValue res = new CandleChartData.CandleValue();
res.Open = ChartCommon.normalizeInRangeY(candle.Open, min, range);
res.Close = ChartCommon.normalizeInRangeY(candle.Close, min, range);
res.High = ChartCommon.normalizeInRangeY(candle.High, min, range);
res.Low = ChartCommon.normalizeInRangeY(candle.Low, min, range);
double duration = candle.Duration;
double start = candle.Start;
if (ThicknessMode == CandleThicknessMode.Fill)
Deflate(ref start, ref duration, ThicknessConstant);
else if (thicknessMode == CandleThicknessMode.Proportional)
Deflate(ref start, ref duration, ThicknessConstant / duration);
double candleEnd = start + duration;
candleEnd = ChartCommon.normalizeInRangeX(candleEnd, min, range);
res.Start = ChartCommon.normalizeInRangeX(start, min, range);
res.Duration = candleEnd - res.Start;
return res;
}
public CandleChartData.CandleValue InterpolateCandleInRect(CandleChartData.CandleValue candle, Rect viewRect)
{
CandleChartData.CandleValue res = new CandleChartData.CandleValue();
res.Open = ChartCommon.interpolateInRectY(viewRect, candle.Open);
res.Close = ChartCommon.interpolateInRectY(viewRect, candle.Close);
res.High = ChartCommon.interpolateInRectY(viewRect, candle.High);
res.Low = ChartCommon.interpolateInRectY(viewRect, candle.Low);
if (res.High < res.Low)
{
double tmp = res.High;
res.High = res.Low;
res.Low = tmp;
tmp = res.Open;
res.Open = res.Close;
res.Close = tmp;
}
double candleEnd = candle.Start + candle.Duration;
candleEnd = ChartCommon.interpolateInRectX(viewRect, candleEnd);
double start = ChartCommon.interpolateInRectX(viewRect, candle.Start);
double duration = candleEnd - start;
if (start > candleEnd)
{
double tmp = start;
start = candleEnd;
candleEnd = tmp;
}
if (ThicknessMode == CandleThicknessMode.Constant)
{
Deflate(ref start, ref duration, ThicknessConstant / duration);
}
res.Start = start;
res.Duration = duration;
return res;
}
StringBuilder mTmpBuilder = new StringBuilder();
protected string FormatItemWithFormat(string format, string open, string close, string high, string low, string start, string duration)
{
FormatItemWithFormat(mTmpBuilder, format, open, close, high, low, start, duration);
return mTmpBuilder.ToString();
}
public string FormatItem(string open, string close, string high, string low, string start, string duration)
{
return FormatItemWithFormat(itemFormat, open, close, high, low, start, duration);
}
public string FormatLow(string open, string close, string high, string low, string start, string duration)
{
return FormatItemWithFormat(lowFormat, open, close, high, low, start, duration);
}
public string FormatHigh(string open, string close, string high, string low, string start, string duration)
{
return FormatItemWithFormat(highFormat, open, close, high, low, start, duration);
}
public string FormatBody(string open, string close, string high, string low, string start, string duration)
{
return FormatItemWithFormat(bodyFormat, open, close, high, low, start, duration);
}
protected void FormatItem(StringBuilder builder, string open, string close, string high, string low, string start, string duration)
{
FormatItemWithFormat(builder, itemFormat, open, close, high, low, start, duration);
}
protected void FormatItemWithFormat(StringBuilder builder, string format, string open, string close, string high, string low, string start, string duration)
{
builder.Length = 0;
builder.Append(format);
builder.Replace("<?open>", open).Replace("<?close>", close).Replace("<?high>", high).Replace("<?low>", low).Replace("<?start>", start).Replace("<?duration>", duration);
}
protected void TransformCandles(IList<CandleChartData.CandleValue> candles, List<CandleChartData.CandleValue> output, Rect viewRect, DoubleVector3 min, DoubleVector3 max)
{
DoubleVector3 range = max - min;
if (Math.Abs(range.x) <= 0.0001f || Math.Abs(range.y) < 0.0001f)
return;
output.Clear();
for (int i = 0; i < candles.Count; i++)
{
CandleChartData.CandleValue candle = candles[i];
candle = InterpolateCandleInRect(NormalizeCandle(candle, min, range), viewRect);
output.Add(candle);
}
}
protected int ClipCandles(IList<CandleChartData.CandleValue> candles, List<CandleChartData.CandleValue> result)
{
result.Clear();
double minX, minY, maxX, maxY, xScroll, yScroll, xSize, ySize, xOut;
GetScrollParams(out minX, out minY, out maxX, out maxY, out xScroll, out yScroll, out xSize, out ySize, out xOut);
double direction = 1.0;
if (minX > maxX)
direction = -1.0;
bool prevOut = true;
int refrenceIndex = 0;
for (int i = 0; i < candles.Count; i++)
{
CandleChartData.CandleValue candle = candles[i];
double candleEnd = candle.Duration + candle.Start;
if (candleEnd* direction >= xScroll* direction && candle.Start* direction <= xOut* direction) // if the candle is within range
{
if (prevOut)
{
refrenceIndex = i;
prevOut = false;
}
result.Add(candle);
}
}
return refrenceIndex;
}
protected override void OnNonHoverted()
{
base.OnNonHoverted();
if (NonHovered != null)
NonHovered.Invoke();
}
protected override void OnItemSelected(object userData)
{
base.OnItemSelected(userData);
CandleEventArgs args = userData as CandleEventArgs;
if (CandleClicked != null)
CandleClicked.Invoke(args);
}
protected override void OnItemHoverted(object userData)
{
base.OnItemHoverted(userData);
CandleEventArgs args = userData as CandleEventArgs;
if (CandleHovered != null)
CandleHovered.Invoke(args);
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 8205d387a1db4a04c85ed37decb56caf
timeCreated: 1491152606
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,657 +0,0 @@
#define Graph_And_Chart_PRO
using ChartAndGraph;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace ChartAndGraph
{
[Serializable]
public class CandleChartData : ScrollableChartData, IInternalCandleData
{
[Serializable]
public struct CandleValue
{
public CandleValue(double open, double high, double low, double close, DateTime start, TimeSpan duration)
{
Open = open;
High = high;
Low = low;
Close = close;
Start = ChartDateUtility.DateToValue(start);
Duration = ChartDateUtility.TimeSpanToValue(duration);
}
public CandleValue(double open, double high, double low, double close, double start, double duration)
{
Open = open;
High = high;
Low = low;
Close = close;
Start = start;
Duration = duration;
}
public double Open;
public double High;
public double Low;
public double Close;
public double Start;
public double Duration;
public bool isUp
{
get { return Close > Open; }
}
public double End
{
get { return Start + Duration; }
}
public DoubleVector2 MidPoint
{
get { return new DoubleVector2(Start + (Duration * 0.5), (Open + Close) * 0.5); }
}
public double Max
{
get
{
return Math.Max(Open, Close);
}
}
public double LowBound
{
get
{
return Math.Min(Math.Min(High, Low), Math.Min(Open, Close));
}
}
public double HighBound
{
get
{
return Math.Max(Math.Max(High, Low), Math.Max(Open, Close));
}
}
public double Min
{
get
{
return Math.Min(Open, Close);
}
}
}
[Serializable]
public class CandleSettings
{
public double LineThickness = 2.0;
public double CandleThicknessMultiplier = 1.0;
public double OutlineThickness = 0.0;
public ChartItemEffect CandleHoverPrefab;
public Material Outline;
public Material Line;
public Material Fill;
public GameObject CandlePrefab;
}
[Serializable]
public class CategoryData : BaseScrollableCategoryData
{
public List<CandleValue> Data = new List<CandleValue>();
public CandleSettings UpCandle = new CandleSettings();
public CandleSettings DownCandle = new CandleSettings();
public double Depth = 0f;
}
class CandleComparer : IComparer<CandleValue>
{
public int Compare(CandleValue x, CandleValue y)
{
if (x.Open < y.Open)
return -1;
if (x.Open > y.Open)
return 1;
return 0;
}
}
[Serializable]
class SerializedCategory
{
public string Name;
[HideInInspector]
public CandleValue[] Data;
[HideInInspector]
public double? MaxX, MaxY, MinX, MinY;
public CandleSettings UpCandle = new CandleSettings();
public CandleSettings DownCandle = new CandleSettings();
public double Depth = 0f;
}
CandleComparer mComparer = new CandleComparer();
[SerializeField]
SerializedCategory[] mSerializedData = new SerializedCategory[0];
event EventHandler IInternalCandleData.InternalViewPortionChanged
{
add
{
ViewPortionChanged += value;
}
remove
{
ViewPortionChanged -= value;
}
}
event EventHandler IInternalCandleData.InternalDataChanged
{
add
{
DataChanged += value;
}
remove
{
DataChanged -= value;
}
}
/// <summary>
/// rename a category. throws and exception on error
/// </summary>
/// <param name="prevName"></param>
/// <param name="newName"></param>
public void RenameCategory(string prevName, string newName)
{
if (prevName == newName)
return;
if (mData.ContainsKey(newName))
throw new ArgumentException(String.Format("A category named {0} already exists", newName));
CategoryData cat = (CategoryData)mData[prevName];
mData.Remove(prevName);
cat.Name = newName;
mData.Add(newName, cat);
RaiseDataChanged();
}
/// <summary>
/// Adds a new category to the candle chart.
/// </summary>
/// <param name="category"></param>
/// <param name="material"></param>
/// <param name="innerFill"></param>
public void AddCategory(string category, CandleSettings up, CandleSettings down, double depth)
{
AddCategory3DCandle(category, up, down, 0f);
}
/// <summary>
/// add category to the candle chart
/// </summary>
/// <param name="category"></param>
/// <param name="up"></param>
/// <param name="down"></param>
/// <param name="depth"></param>
public void AddCategory3DCandle(string category, CandleSettings up, CandleSettings down, double depth)
{
if (mData.ContainsKey(category))
throw new ArgumentException(String.Format("A category named {0} already exists", category));
CategoryData data = new CategoryData();
mData.Add(category, data);
data.Name = category;
data.DownCandle = down;
data.UpCandle = up;
data.Depth = depth;
RaiseDataChanged();
}
/// <summary>
/// removed a category from the DataSource. returnes true on success , or false if the category does not exist
/// </summary>
/// <param name="category"></param>
/// <returns></returns>
public bool RemoveCategory(string category)
{
return mData.Remove(category);
}
public void SetDownCandle(string category, CandleSettings down)
{
if (mData.ContainsKey(category) == false)
{
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
return;
}
CategoryData data = (CategoryData)mData[category];
data.DownCandle = down;
RaiseDataChanged();
}
public void SetUpCandle(string category, CandleSettings up)
{
if (mData.ContainsKey(category) == false)
{
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
return;
}
CategoryData data = (CategoryData)mData[category];
data.UpCandle = up;
RaiseDataChanged();
}
/// <summary>
/// sets the depth for a 3d graph category
/// </summary>
/// <param name="category"></param>
/// <param name="depth"></param>
public void Set3DCategoryDepth(string category, double depth)
{
if (mData.ContainsKey(category) == false)
{
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
return;
}
if (depth < 0)
depth = 0f;
CategoryData data = (CategoryData)mData[category];
data.Depth = depth;
RaiseDataChanged();
}
/// <summary>
/// clears all the data for the selected category
/// </summary>
/// <param name="category"></param>
public void ClearCategory(string category)
{
if (mData.ContainsKey(category) == false)
{
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
return;
}
mData[category].MaxX = null;
mData[category].MaxY = null;
mData[category].MinX = null;
mData[category].MinY = null;
((CategoryData)mData[category]).Data.Clear();
RaiseDataChanged();
}
/// <summary>
/// gets the candle at the specified index for a given category
/// </summary>
/// <param name="category"></param>
/// <param name="index"></param>
/// <returns></returns>
public int GetCandleCount(string category)
{
if (mData.ContainsKey(category) == false)
{
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
return 0;
}
CategoryData data = (CategoryData)mData[category];
return data.Data.Count;
}
/// <summary>
/// gets the candle at the specified index for a given category
/// </summary>
/// <param name="category"></param>
/// <param name="index"></param>
/// <returns></returns>
public CandleValue GetCandle(string category, int index)
{
if (mData.ContainsKey(category) == false)
{
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
return new CandleValue();
}
CategoryData data = (CategoryData)mData[category];
return data.Data[index];
}
/// <summary>
/// returns the total amount of candles in the given category
/// </summary>
/// <param name="category"></param>
/// <returns></returns>
public int GetTotalCandlesInCategory(string category)
{
if (mData.ContainsKey(category) == false)
{
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
return 0;
}
CategoryData data = (CategoryData)mData[category];
return data.Data.Count;
}
/// <summary>
/// use this to modify candles in realtime.
/// </summary>
/// <param name="category"></param>
/// <param name="candle"></param>
public void ModifyCandleInCategory(string category, int candleIndex, double open, double high, double low, double close)
{
if (mData.ContainsKey(category) == false)
{
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
return;
}
CategoryData data = (CategoryData)mData[category];
List<CandleValue> candles = data.Data;
if (candleIndex == -1)
candleIndex = data.Data.Count - 1;
if (candleIndex < 0 || candleIndex >= candles.Count)
{
Debug.LogWarning("Candle index is out of range, call is ignored");
return;
}
double candleMax = Math.Max(Math.Max(open, close), Math.Max(high, low));
double candleMin = Math.Min(Math.Min(open, close), Math.Min(high, low));
if (data.MaxY.HasValue == false || data.MaxY.Value < candleMax)
data.MaxY = candleMax;
if (data.MinY.HasValue == false || data.MinY.Value > candleMin)
data.MinY = candleMin;
CandleValue candle = data.Data[candleIndex];
candle.Open = open;
candle.Close = close;
candle.High = high;
candle.Low = low;
data.Data[candleIndex] = candle;
RaiseRealtimeDataChanged(candleIndex, category);
}
/// <summary>
/// removes a candle from a category
/// </summary>
/// <param name="category"></param>
/// <param name="index"></param>
public void RemoveCandleInCategory(string category, int candleIndex)
{
if (mData.ContainsKey(category) == false)
{
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
return;
}
CategoryData data = (CategoryData)mData[category];
List<CandleValue> candles = data.Data;
if (candleIndex < 0 || candleIndex >= candles.Count)
{
Debug.LogWarning("Candle index is out of range, call is ignored");
return;
}
data.Data.RemoveAt(candleIndex);
RaiseRealtimeDataChanged(candleIndex, category);
}
/// <summary>
/// use this to modify candles in realtime. this overload modifies the last candle and can be used for realtime candle data stream
/// </summary>
/// <param name="category"></param>
/// <param name="candle"></param>
public void ModifyLastCandleInCategory(string category, double open, double high, double low, double close)
{
ModifyCandleInCategory(category, -1, open, high, low, close);
}
class Slider : BaseSlider
{
public string category;
public double from;
public int index;
public double to;
public double current;
public double y;
private CandleChartData mParent;
public Slider(CandleChartData parent)
{
mParent = parent;
}
public override DoubleVector2 Max
{
get
{
return new DoubleVector2(current, y);
}
}
public override DoubleVector2 Min
{
get
{
return new DoubleVector2(current, y);
}
}
public override string Category { get { return category; } }
public override int MinIndex
{
get { return index; }
}
public override bool Update()
{
BaseScrollableCategoryData baseData;
if (mParent.mData.TryGetValue(category, out baseData) == false)
return true;
double time = Time.time;
time -= StartTime;
if (Duration <= 0.0001f)
time = 1f;
else
{
time /= Duration;
Math.Max(0.0, Math.Min(time, 1.0));
}
current = from * (1.0 - time) + to * time;
if (time >= 1f)
{
mParent.ModifyMinMax(baseData, new DoubleVector3(current, y, 0.0));
return true;
}
return false;
}
}
/// <summary>
/// adds a point to the category. The points are sorted by their x value automatically
/// </summary>
/// <param name="category"></param>
/// <param name="point"></param>
public void AddCandleToCategory(string category, CandleValue candle, float autoScrollSlideTime = 0f)
{
if (mData.ContainsKey(category) == false)
{
Debug.LogWarning("Invalid category name. Make sure the category is present in the chart");
return;
}
CategoryData data = (CategoryData)mData[category];
List<CandleValue> candles = data.Data;
double start = candle.Start;
double end = candle.Start + candle.Duration;
double candleMax = Math.Max(Math.Max(candle.Open, candle.Close), Math.Max(candle.High, candle.Low));
double candleMin = Math.Min(Math.Min(candle.Open, candle.Close), Math.Min(candle.High, candle.Low));
if (autoScrollSlideTime <= 0f)
{
if (data.MaxX.HasValue == false || data.MaxX.Value < end)
data.MaxX = end;
}
if (data.MinX.HasValue == false || data.MinX.Value > start)
data.MinX = start;
if (data.MaxY.HasValue == false || data.MaxY.Value < candleMax)
data.MaxY = candleMax;
if (data.MinY.HasValue == false || data.MinY.Value > candleMin)
data.MinY = candleMin;
if (candles.Count > 0)
{
if (candles[candles.Count - 1].Start < candle.Start)
{
if (autoScrollSlideTime > 0f)
{
Slider s = new Slider(this);
s.category = category;
s.from = candles[candles.Count - 1].End;
s.to = end;
s.StartTime = Time.time;
s.Duration = autoScrollSlideTime;
s.y = (candleMax + candleMin) * 0.5;
s.index = candles.Count - 1;
mSliders.Add(s);
}
candles.Add(candle);
RaiseRealtimeDataChanged(candles.Count-1, category);
return;
}
}
int search = candles.BinarySearch(candle, mComparer);
if (search < 0)
search = ~search;
candles.Insert(search, candle);
RaiseRealtimeDataChanged(search, category);
}
double IInternalCandleData.GetMaxValue(int axis, bool dataValue)
{
return GetMaxValue(axis, dataValue);
}
double IInternalCandleData.GetMinValue(int axis, bool dataValue)
{
return GetMinValue(axis, dataValue);
}
public override void OnAfterDeserialize()
{
if (mSerializedData == null)
return;
mData.Clear();
mSuspendEvents = true;
for (int i = 0; i < mSerializedData.Length; i++)
{
SerializedCategory cat = mSerializedData[i];
if (cat.Depth < 0)
cat.Depth = 0f;
string name = cat.Name;
AddCategory3DCandle(name, cat.UpCandle, cat.DownCandle, cat.Depth);
CategoryData data = (CategoryData)mData[name];
data.Data.AddRange(cat.Data);
data.MaxX = cat.MaxX;
data.MaxY = cat.MaxY;
data.MinX = cat.MinX;
data.MinY = cat.MinY;
}
mSuspendEvents = false;
}
public override void OnBeforeSerialize()
{
List<SerializedCategory> serialized = new List<SerializedCategory>();
foreach (KeyValuePair<string, CategoryData> pair in mData.Select(x => new KeyValuePair<string, CategoryData>(x.Key, (CategoryData)x.Value)))
{
SerializedCategory cat = new SerializedCategory();
cat.Name = pair.Key;
cat.MaxX = pair.Value.MaxX;
cat.MinX = pair.Value.MinX;
cat.MaxY = pair.Value.MaxY;
cat.MinY = pair.Value.MinY;
cat.UpCandle = pair.Value.UpCandle;
cat.DownCandle = pair.Value.DownCandle;
cat.Depth = pair.Value.Depth;
cat.Data = pair.Value.Data.ToArray();
if (cat.Depth < 0)
cat.Depth = 0f;
serialized.Add(cat);
}
mSerializedData = serialized.ToArray();
}
public override BaseScrollableCategoryData GetDefaultCategory()
{
throw new NotImplementedException();
}
protected override void InnerClearCategory(string category)
{
throw new NotImplementedException();
}
protected override void AppendDatum(string category, MixedSeriesGenericValue value)
{
throw new NotImplementedException();
}
protected override void AppendDatum(string category, IList<MixedSeriesGenericValue> value)
{
throw new NotImplementedException();
}
protected override bool AddCategory(string category, BaseScrollableCategoryData data)
{
throw new NotImplementedException();
}
int IInternalCandleData.TotalCategories
{
get { return mData.Count; }
}
event Action<int,string> IInternalCandleData.InternalRealTimeDataChanged
{
add
{
RealtimeDataChanged += value;
}
remove
{
RealtimeDataChanged -= value;
}
}
IEnumerable<CategoryData> IInternalCandleData.Categories
{
get
{
return mData.Values.Select(x => (CategoryData)x);
}
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: e8db3da49553a7d449f2082158192d56
timeCreated: 1491152608
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,136 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace ChartAndGraph
{
class CanvasCandle : MonoBehaviour, ICandleCreator
{
List<CandleChartData.CandleValue> mEmptyCandle = new List<CandleChartData.CandleValue>();
HashSet<CanvasCandleGraphic> mOccupied = new HashSet<CanvasCandleGraphic>();
CanvasCandleGraphic mCandle, mLine;
CanvasCandleGraphic mOutline;
/// <summary>
/// The selected index is hovered about the specified point
/// </summary>
public event EventHandlingGraphic.GraphicEvent Hover;
/// <summary>
/// The selected index is clicked about the specified point
/// </summary>
public event EventHandlingGraphic.GraphicEvent Click;
/// <summary>
/// The currently hovered and selected objects are no longer selected or hovered.
/// </summary>
public event Action Leave;
private CanvasCandleGraphic CreateCandleGraphic()
{
GameObject obj = ChartCommon.CreateCanvasChartItem();
CanvasCandleGraphic graphic = obj.AddComponent<CanvasCandleGraphic>();
graphic.maskable = true;
RectTransform rect = obj.GetComponent<RectTransform>();
rect.SetParent(transform, false);
rect.anchoredPosition = Vector3.zero;
rect.rotation = Quaternion.identity;
rect.localScale = new Vector3(1f, 1f, 1f);
HookEventsForGraphic(graphic);
return graphic;
}
void HookEventsForGraphic(CanvasCandleGraphic graphic)
{
graphic.Hover += (index, type, data, position) => { Candle_Hover(graphic, index, type, data, position); };
graphic.Click += (index, type, data, position) => { Candle_Click(graphic, index, type, data, position); }; ;
graphic.Leave += () => { Candle_Leave(graphic); };
}
public void Clear()
{
ChartCommon.SafeDestroy(mCandle);
ChartCommon.SafeDestroy(mLine);
ChartCommon.SafeDestroy(mOutline);
}
public void SetRefrenceIndex(int index)
{
if (mCandle != null)
mCandle.SetRefrenceIndex(index);
if (mLine != null)
mCandle.SetRefrenceIndex(index);
if (mOutline != null)
mOutline.SetRefrenceIndex(index);
}
public void Generate(CandleChart parent, Rect viewRect, IList<CandleChartData.CandleValue> value, CandleChartData.CandleSettings settings)
{
if (parent.IsCanvas == false)
{
Debug.LogWarning("prefab is meant to be used with canvas candle chart only");
return;
}
if (mCandle == null)
mCandle = CreateCandleGraphic();
if (settings.Fill == null || settings.CandleThicknessMultiplier < 0.0001f)
mCandle.SetCandle(0, mEmptyCandle, settings);
else
mCandle.SetCandle(0, value, settings);
mCandle.HoverTransform(transform);
mCandle.SetViewRect(viewRect, new Rect());
mCandle.SetHoverPrefab(settings.CandleHoverPrefab);
mCandle.material = settings.Fill;
if (mLine == null)
mLine = CreateCandleGraphic();
if (settings.Line == null || settings.LineThickness < 0.0001f)
mLine.SetCandle(1, mEmptyCandle, settings);
else
mLine.SetCandle(1, value, settings);
mLine.HoverTransform(transform);
mLine.SetHoverPrefab(settings.CandleHoverPrefab);
mLine.material = settings.Line;
mLine.SetViewRect(viewRect, new Rect());
if (mOutline == null)
mOutline = CreateCandleGraphic();
mOutline.material = settings.Outline;
mOutline.SetViewRect(viewRect, new Rect());
if (settings.Outline == null || settings.OutlineThickness < 0.0001f)
mOutline.SetCandle(2, mEmptyCandle, settings);
else
mOutline.SetCandle(2, value, settings);
}
private void Candle_Leave(CanvasCandleGraphic graphic)
{
if (mOccupied.Remove(graphic))
{
if (mOccupied.Count == 0)
{
if (Leave != null)
Leave();
}
}
}
private void Candle_Click(CanvasCandleGraphic graphic, int index, int type, object data, Vector2 position)
{
mOccupied.Add(graphic);
position = graphic.transform.TransformPoint(position);
if (Click != null)
Click(index, type, data, position);
}
private void Candle_Hover(CanvasCandleGraphic graphic, int index, int type, object data, Vector2 position)
{
mOccupied.Add(graphic);
position = graphic.transform.TransformPoint(position);
if (Hover != null)
Hover(index, type, data, position);
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 663704866ea20c443b89affc7c7efb2f
timeCreated: 1491395378
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,548 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace ChartAndGraph
{
class CanvasCandleChart : CandleChart
{
List<CandleChartData.CandleValue> mClipped = new List<CandleChartData.CandleValue>();
List<CandleChartData.CandleValue> mTransformed = new List<CandleChartData.CandleValue>();
List<CandleChartData.CandleValue> mCurrentSeries = new List<CandleChartData.CandleValue>();
int mTmpCurrentIndex = 0;
List<int> mUpToIndex = new List<int>();
List<int> mDownToIndex = new List<int>();
Dictionary<string, CategoryObject> mCategoryObjects = new Dictionary<string, CategoryObject>();
StringBuilder mRealtimeStringBuilder = new StringBuilder();
HashSet<string> mOccupiedCateogies = new HashSet<string>();
List<int> mTmpToRemove = new List<int>();
private bool SupressRealtimeGeneration = false;
[SerializeField]
private bool fitToContainer = false;
public bool FitToContainer
{
get { return fitToContainer; }
set
{
fitToContainer = value;
OnPropertyUpdated();
}
}
[SerializeField]
private ChartMagin fitMargin;
public ChartMagin FitMargin
{
get { return fitMargin; }
set
{
fitMargin = value;
OnPropertyUpdated();
}
}
protected override float TotalDepthLink
{
get
{
return 0f;
}
}
public override bool SupportRealtimeGeneration
{
get
{
return true;
}
}
public override bool IsCanvas
{
get
{
return true;
}
}
class CategoryObject
{
public CanvasChartMesh mItemLabels;
public CanvasCandle mUp;
public CanvasCandle mDown;
public Dictionary<int, string> mCahced = new Dictionary<int, string>();
public HashSet<CanvasCandle> mOccupiedCandles = new HashSet<CanvasCandle>();
private CanvasCandleChart mParent;
/// <summary>
/// The selected index is hovered about the specified point
/// </summary>
public event EventHandlingGraphic.GraphicEvent Hover;
/// <summary>
/// The selected index is clicked about the specified point
/// </summary>
public event EventHandlingGraphic.GraphicEvent Click;
/// <summary>
/// The currently hovered and selected objects are no longer selected or hovered.
/// </summary>
public event Action Leave;
public CategoryObject(CanvasCandleChart parent)
{
mParent = parent;
}
public void HookEvents()
{
HookEvents(mUp, true);
HookEvents(mDown, false);
}
void HookEvents(CanvasCandle candle, bool isUp)
{
if (candle == null)
return;
candle.Leave += () => mLeave(candle);
candle.Hover += (index, type, data, position) => { mHover(candle, mParent.MapIndex(index, isUp), type, data, position); };
candle.Click += (index, type, data, position) => { mClick(candle, mParent.MapIndex(index, isUp), type, data, position); };
}
private void mClick(CanvasCandle candle, int index, int type, object data, Vector2 position)
{
mOccupiedCandles.Add(candle);
if (Click != null)
Click(index, type, data, position);
}
private void mHover(CanvasCandle candle, int index, int type, object data, Vector2 position)
{
mOccupiedCandles.Add(candle);
if (Hover != null)
Hover(index, type, data, position);
}
private void mLeave(CanvasCandle candle)
{
if (mOccupiedCandles.Remove(candle))
{
if (mOccupiedCandles.Count == 0)
{
if (Leave != null)
Leave();
}
}
}
}
protected override bool ShouldFitCanvas { get { return true; } }
protected override FitType FitAspectCanvas
{
get
{
return FitType.Aspect;
}
}
private CanvasCandle CreateDataObject(CandleChartData.CategoryData data, GameObject rectMask)
{
GameObject obj = new GameObject("Candles", typeof(RectTransform));
ChartCommon.HideObject(obj, hideHierarchy);
obj.AddComponent<ChartItem>();
RectTransform t = obj.GetComponent<RectTransform>();
obj.AddComponent<CanvasRenderer>();
CanvasCandle candles = obj.AddComponent<CanvasCandle>();
t.SetParent(rectMask.transform, false);
t.localScale = new Vector3(1f, 1f, 1f);
t.anchorMin = new Vector2(0f, 0f);
t.anchorMax = new Vector2(1f, 1f);
t.sizeDelta = new Vector2(0f, 0f);
t.anchorMin = new Vector2(0f, 0f);
t.anchorMax = new Vector2(0f, 0f);
t.anchoredPosition = Vector3.zero;
return candles;
}
protected override double GetCategoryDepth(string category)
{
return 0.0;
}
public override void GenerateRealtime()
{
if (SupressRealtimeGeneration)
return;
base.GenerateRealtime();
double minX = ((IInternalCandleData)Data).GetMinValue(0, false);
double minY = ((IInternalCandleData)Data).GetMinValue(1, false);
double maxX = ((IInternalCandleData)Data).GetMaxValue(0, false);
double maxY = ((IInternalCandleData)Data).GetMaxValue(1, false);
double xScroll = GetScrollOffset(0);
double yScroll = GetScrollOffset(1);
double xSize = maxX - minX;
double ySize = maxY - minY;
double xOut = minX + xScroll + xSize;
double yOut = minY + yScroll + ySize;
DoubleVector3 min = new DoubleVector3(xScroll + minX, yScroll + minY);
DoubleVector3 max = new DoubleVector3(xOut, yOut);
Rect viewRect = new Rect(0f, 0f, widthRatio, heightRatio);
ClearBillboardCategories();
bool edit = false;
foreach (CandleChartData.CategoryData data in ((IInternalCandleData)Data).Categories)
{
CategoryObject obj = null;
if (mCategoryObjects.TryGetValue(data.Name, out obj) == false)
continue;
mClipped.Clear();
mTransformed.Clear();
int refrenceIndex = ClipCandles(data.Data, mClipped);
TransformCandles(mClipped, mTransformed, viewRect, min, max);
if (data.Data.Count == 0 && ChartCommon.IsInEditMode)
{
edit = true;
}
mTmpToRemove.Clear();
int range = refrenceIndex + mClipped.Count;
foreach (int key in obj.mCahced.Keys)
{
if (key < refrenceIndex || key > range)
mTmpToRemove.Add(key);
}
for (int i = 0; i < mTmpToRemove.Count; i++)
obj.mCahced.Remove(mTmpToRemove[i]);
obj.mCahced.Remove(data.Data.Count - 1); // never store the last point cache , it might be intepolating by the realtime feature
if (data.Data.Count == 0)
continue;
GenerateItemLabels(true, obj, data, viewRect, refrenceIndex, edit);
if (obj.mUp != null)
{
FillCurrentSeries(true, refrenceIndex);
obj.mUp.Generate(this, viewRect, mCurrentSeries, data.UpCandle);
}
if (obj.mDown != null)
{
FillCurrentSeries(false, refrenceIndex);
obj.mDown.Generate(this, viewRect, mCurrentSeries, data.DownCandle);
}
}
}
protected override void ClearChart()
{
base.ClearChart();
ClearBillboard();
mActiveTexts.Clear();
mCategoryObjects.Clear();
}
void GenerateItemLabels(bool realTime, CategoryObject categoryObj, CandleChartData.CategoryData data, Rect viewRect, int refrenceIndex, bool edit)
{
if (mItemLabels != null && mItemLabels.isActiveAndEnabled)
{
CanvasChartMesh m = null;
if (realTime)
{
m = categoryObj.mItemLabels;
if (m == null)
return;
m.Clear();
}
else
{
m = new CanvasChartMesh(true);
m.RecycleText = true;
categoryObj.mItemLabels = m;
}
Rect textRect = viewRect;
textRect.xMin -= 1f;
textRect.yMin -= 1f;
textRect.xMax += 1f;
textRect.yMax += 1f;
for (int i = 0; i < mTransformed.Count; i++)
{
Vector2 pointValue = mTransformed[i].MidPoint.ToVector2();
if (textRect.Contains(pointValue) == false)
continue;
CandleChartData.CandleValue candleVal = mTransformed[i];
int candleIndex = i + refrenceIndex;
if (edit == false)
candleVal = data.Data[i + refrenceIndex];
Vector3 labelPos = ((Vector3)pointValue) + new Vector3(mItemLabels.Location.Breadth, mItemLabels.Seperation, mItemLabels.Location.Depth);
if (mItemLabels.Alignment == ChartLabelAlignment.Base)
labelPos.y -= (float)mTransformed[i].MidPoint.y;
string toSet;
if (realTime == false || categoryObj.mCahced.TryGetValue(candleIndex, out toSet) == false)
{
string Open = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Open, 0.0), mVerticalAxis, false);
string Close = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Close, 0.0), mVerticalAxis, false);
string High = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.High, 0.0), mVerticalAxis, false);
string Low = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Low, 0.0), mVerticalAxis, false);
string Start = StringFromAxisFormat(new DoubleVector3(candleVal.Start, candleVal.Open, 0.0), mHorizontalAxis, true);
string Duration = StringFromAxisFormat(new DoubleVector3(candleVal.Duration, candleVal.Open, 0.0), mHorizontalAxis, true);
FormatItem(mRealtimeStringBuilder, Open, Close, High, Low, Start, Duration);
toSet = mItemLabels.TextFormat.Format(mRealtimeStringBuilder.ToString(), data.Name, "");
categoryObj.mCahced[candleIndex] = toSet;
}
labelPos -= new Vector3(CanvasFitOffset.x * TotalWidth, CanvasFitOffset.y * TotalHeight, 0f);
BillboardText billboard = m.AddText(this, mItemLabels.TextPrefab, transform, mItemLabels.FontSize, mItemLabels.FontSharpness, toSet, labelPos.x, labelPos.y, labelPos.z, 0f, null);
TextController.AddText(billboard);
AddBillboardText(data.Name, i + refrenceIndex, billboard);
}
if (realTime)
{
m.DestoryRecycled();
if (m.TextObjects != null)
{
foreach (BillboardText text in m.TextObjects)
{
((IInternalUse)this).InternalTextController.AddText(text);
}
}
}
}
}
bool UpPredicate(CandleChartData.CandleValue x)
{
if (x.isUp)
mUpToIndex.Add(mTmpCurrentIndex);
mTmpCurrentIndex++;
return x.isUp;
}
bool DownPredicate(CandleChartData.CandleValue x)
{
if (x.isUp == false)
mDownToIndex.Add(mTmpCurrentIndex);
mTmpCurrentIndex++;
return !x.isUp;
}
void FillCurrentSeries(bool isUp, int refrenceIndex)
{
mTmpCurrentIndex = refrenceIndex;
mCurrentSeries.Clear();
if (isUp)
{
mUpToIndex.Clear();
mCurrentSeries.AddRange(mTransformed.Where(UpPredicate));
}
else
{
mDownToIndex.Clear();
mCurrentSeries.AddRange(mTransformed.Where(DownPredicate));
}
}
int MapIndex(int index, bool isUp)
{
if (isUp)
{
if (mUpToIndex.Count <= index)
return index;
return mUpToIndex[index];
}
if (mDownToIndex.Count <= index)
return index;
return mDownToIndex[index];
}
public override void InternalGenerateChart()
{
if (gameObject.activeInHierarchy == false)
return;
base.InternalGenerateChart();
if (FitToContainer)
{
RectTransform trans = GetComponent<RectTransform>();
widthRatio = trans.rect.width;
heightRatio = trans.rect.height;
}
ClearChart();
if (Data == null)
return;
GenerateAxis(true);
double minX = ((IInternalCandleData)Data).GetMinValue(0, false);
double minY = ((IInternalCandleData)Data).GetMinValue(1, false);
double maxX = ((IInternalCandleData)Data).GetMaxValue(0, false);
double maxY = ((IInternalCandleData)Data).GetMaxValue(1, false);
double xScroll = GetScrollOffset(0);
double yScroll = GetScrollOffset(1);
double xSize = maxX - minX;
double ySize = maxY - minY;
double xOut = minX + xScroll + xSize;
double yOut = minY + yScroll + ySize;
DoubleVector3 min = new DoubleVector3(xScroll + minX, yScroll + minY);
DoubleVector3 max = new DoubleVector3(xOut, yOut);
Rect viewRect = new Rect(0f, 0f, widthRatio, heightRatio);
int total = ((IInternalCandleData)Data).TotalCategories + 1;
bool edit = false;
ClearBillboard();
mActiveTexts.Clear();
int index = 0;
GameObject mask = CreateRectMask(viewRect);
foreach (CandleChartData.CategoryData data in ((IInternalCandleData)Data).Categories)
{
mClipped.Clear();
mTransformed.Clear();
int refrenceIndex = ClipCandles(data.Data, mClipped);
TransformCandles(mClipped, mTransformed, viewRect, min, max);
if (data.Data.Count == 0 && ChartCommon.IsInEditMode)
{
int tmpIndex = total - 1 - index;
float low = (((float)tmpIndex) / (float)total);
float high = (((float)tmpIndex + 1) / (float)total);
float y1 = Mathf.Lerp(high, low, 0.6f);
float y2 = Mathf.Lerp(high, low, 0.3f);
mTransformed.Clear();
mTransformed.Add(InterpolateCandleInRect(new CandleChartData.CandleValue(y1, high, low, y2, 0.1, 0.1), viewRect));
mTransformed.Add(InterpolateCandleInRect(new CandleChartData.CandleValue(y1, low, high, y2, 0.5, 0.2), viewRect));
edit = true;
index++;
}
CategoryObject categoryObj = new CategoryObject(this);
CanvasCandle up = CreateDataObject(data, mask);
CanvasCandle down = CreateDataObject(data, mask);
FillCurrentSeries(true, refrenceIndex);
up.Generate(this, viewRect, mCurrentSeries, data.UpCandle);
FillCurrentSeries(false, refrenceIndex);
down.Generate(this, viewRect, mCurrentSeries, data.DownCandle);
string catName = data.Name;
categoryObj.mUp = up;
categoryObj.mDown = down;
categoryObj.HookEvents();
GenerateItemLabels(false, categoryObj, data, viewRect, refrenceIndex, edit);
categoryObj.Hover += (idx, t, d, pos) => { Category_Hover(catName, idx, t, d, pos); };
categoryObj.Click += (idx, t, d, pos) => { Category_Click(catName, idx, t, d, pos); };
categoryObj.Leave += () => { Category_Leave(catName); };
mCategoryObjects[catName] = categoryObj;
}
}
void Category_Hover(string category, int index, int type, object data, Vector2 position)
{
CandleChartData.CandleValue candle = Data.GetCandle(category, index);
Dictionary<int, BillboardText> catgoryTexts;
BillboardText b;
if (mTexts.TryGetValue(category, out catgoryTexts))
{
if (catgoryTexts.TryGetValue(index, out b))
SelectActiveText(b);
}
Rect selection = new Rect();
if (data != null && data is Rect)
selection = (Rect)data;
OnItemHoverted(new CandleEventArgs(index, type, selection, position, candle, category));
}
/// <summary>
/// handles click of the category
/// </summary>
/// <param name="category"></param>
/// <param name="index"></param>
/// <param name="type"></param>
/// <param name="data"></param>
/// <param name="position"></param>
void Category_Click(string category, int index, int type, object data, Vector2 position)
{
CandleChartData.CandleValue candle = Data.GetCandle(category, index);
Dictionary<int, BillboardText> catgoryTexts;
BillboardText b;
if (mTexts.TryGetValue(category, out catgoryTexts))
{
if (catgoryTexts.TryGetValue(index, out b))
SelectActiveText(b);
}
Rect selection = new Rect();
if (data != null && data is Rect)
selection = (Rect)data;
OnItemSelected(new CandleEventArgs(index, type, selection, position, candle, category));
}
void Category_Leave(string cat)
{
TriggerActiveTextsOut();
OnItemLeave(new CandleEventArgs(0, 0, new Rect(), new Vector3(), new CandleChartData.CandleValue(), cat),"none");
}
protected override void OnItemHoverted(object userData)
{
base.OnItemHoverted(userData);
var args = userData as CandleEventArgs;
mOccupiedCateogies.Add(args.Category);
}
protected override void OnItemSelected(object userData)
{
base.OnItemSelected(userData);
var args = userData as CandleEventArgs;
mOccupiedCateogies.Add(args.Category);
}
protected override void OnItemLeave(object userData,string type)
{
//base.OnItemLeave(userData);
CandleEventArgs args = userData as CandleEventArgs;
if (args == null)
return;
string category = args.Category;
mOccupiedCateogies.Remove(category);
mOccupiedCateogies.RemoveWhere(x => !Data.HasCategory(x));
if (mOccupiedCateogies.Count == 0)
{
if (NonHovered != null)
NonHovered.Invoke();
}
}
internal override void SetAsMixedSeries()
{
throw new NotImplementedException();
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 25a10981261111f4bbc2ed5f2cd476f7
timeCreated: 1501868716
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,506 +0,0 @@
#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 CanvasCandleGraphic : EventHandlingGraphic
{
CandleChartData.CandleSettings mCandleSettings;
List<CandleChartData.CandleValue> mCandles = new List<CandleChartData.CandleValue>();
int mPart;
UIVertex[] mTmpVerts = new UIVertex[4];
Vector2 mMin, mMax;
protected override Vector2 Min
{
get
{
return mMin;
}
}
protected override Vector2 Max
{
get
{
return mMax;
}
}
protected Rect RectFromIndex(int index, int type, Rect Default)
{
if (index >= mCandles.Count)
return Default;
CandleChartData.CandleValue candle = mCandles[index];
float max = (float)candle.Max;
float min = (float)candle.Min;
float start = (float)candle.Start;
float end = (float)(candle.Start + candle.Duration);
float mid = (start + end) * 0.5f;
if (type == 0)
return ChartCommon.RectFromCenter(mid, (float)mCandleSettings.LineThickness, max, (float)candle.High);
if (type == 2)
return ChartCommon.RectFromCenter(mid, (float)mCandleSettings.LineThickness, (float)candle.Low, min);
return ChartCommon.RectFromCenter(mid, (float)(mCandleSettings.CandleThicknessMultiplier * candle.Duration), min, max);
}
protected override void SetUpHoverObject(ChartItemEffect hover, int index, int type, object selectionData)
{
Rect selectionRect = (Rect)selectionData;
selectionRect = RectFromIndex(index, type, selectionRect);
hover.ItemData = selectionRect;
SetupHoverObjectToRect(hover, index, type, selectionRect);
}
protected void PickLine(Vector3 mouse, out int pickedIndex, out int pickedType, out object selectionData)
{
pickedIndex = -1;
pickedType = -1;
selectionData = null;
for (int i = 0; i < mCandles.Count; i++)
{
CandleChartData.CandleValue candle = mCandles[i];
float max = (float)candle.Max;
float min = (float)candle.Min;
float start = (float)candle.Start;
float end = (float)(candle.Start + candle.Duration);
float mid = (start + end) * 0.5f;
Rect high = ChartCommon.RectFromCenter(mid, (float)mCandleSettings.LineThickness, max, (float)candle.High);
Rect low = ChartCommon.RectFromCenter(mid, (float)mCandleSettings.LineThickness, (float)candle.Low, min);
if (high.Contains(mouse))
{
selectionData = high;
pickedType = 0;
pickedIndex = i;
return;
}
if (low.Contains(mouse))
{
selectionData = low;
pickedType = 2;
pickedIndex = i;
return;
}
}
}
protected void PickBody(Vector3 mouse, out int pickedIndex, out int pickedType, out object selectionData)
{
pickedIndex = -1;
pickedType = -1;
selectionData = null;
for (int i = 0; i < mCandles.Count; i++)
{
CandleChartData.CandleValue candle = mCandles[i];
float max = (float)candle.Max;
float min = (float)candle.Min;
float start = (float)candle.Start;
float end = (float)(candle.Start + candle.Duration);
float mid = (start + end) * 0.5f;
Rect Body = ChartCommon.RectFromCenter(mid, (float)(mCandleSettings.CandleThicknessMultiplier * candle.Duration), min, max);
if (Body.Contains(mouse))
{
selectionData = Body;
pickedType = 1;
pickedIndex = i;
return;
}
}
}
protected override void Pick(Vector3 mouse, out int pickedIndex, out int pickedType, out object selectionData)
{
if (mPart == 0)
PickBody(mouse, out pickedIndex, out pickedType, out selectionData);
else
PickLine(mouse, out pickedIndex, out pickedType, out selectionData);
if (pickedIndex >= 0)
pickedIndex += refrenceIndex;
}
protected override float MouseInThreshold
{
get
{
return Sensitivity;
}
}
public void ClearCandles()
{
mCandles = null;
SetAllDirty();
Rebuild(CanvasUpdate.PreRender);
}
public void SetCandle(int part, IList<CandleChartData.CandleValue> candles, CandleChartData.CandleSettings settings)
{
mPart = part;
mCandles.Clear();
mCandles.AddRange(candles);
mCandleSettings = settings;
double minX = double.PositiveInfinity;
double minY = double.PositiveInfinity;
double maxX = double.NegativeInfinity;
double maxY = double.NegativeInfinity;
for (int i = 0; i < mCandles.Count; i++)
{
var candle = mCandles[i];
minY = Math.Min(candle.LowBound, minY);
maxY = Math.Max(candle.HighBound, maxY);
minX = Math.Min(minX, candle.Start);
maxX = Math.Max(maxX, candle.Start + candle.Duration);
}
mMin = new Vector2((float)minX, (float)minY);
mMax = new Vector2((float)maxX, (float)maxY);
SetAllDirty();
Rebuild(CanvasUpdate.PreRender);
SetUpAllHoverObjects();
}
IEnumerable<UIVertex> getOutline()
{
UIVertex v = new UIVertex();
if (mCandles == null)
yield break;
float outlineThickness = (float)mCandleSettings.OutlineThickness * 0.5f;
for (int i = 0; i < mCandles.Count; i++)
{
CandleChartData.CandleValue candle = mCandles[i];
float max = (float)Math.Max(candle.Open, candle.Close);
float min = (float)Math.Min(candle.Open, candle.Close);
float start = (float)candle.Start;
float end = (float)(candle.Start + candle.Duration);
float mid = (start + end) * 0.5f;
float thickness = (float)(mCandleSettings.CandleThicknessMultiplier * candle.Duration * 0.5);
//long and dirty part the defines all the verices of the candle outline
//outline of the body
v.position = new Vector3(mid - thickness - outlineThickness, max, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid - thickness + outlineThickness, max, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid - thickness - outlineThickness, min, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid - thickness + outlineThickness, min, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
//outline of the body
v.position = new Vector3(mid + thickness - outlineThickness, max, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid + thickness + outlineThickness, max, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid + thickness - outlineThickness, min, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid + thickness + outlineThickness, min, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
//outline of the high line
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness - outlineThickness, (float)candle.High, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness + outlineThickness, (float)candle.High, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness - outlineThickness, max, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness + outlineThickness, max, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
//outline of the high line
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness - outlineThickness, (float)candle.High, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness + outlineThickness, (float)candle.High, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness - outlineThickness, max, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness + outlineThickness, max, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
//outline of the low line
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness - outlineThickness, min, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness + outlineThickness, min, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness - outlineThickness, (float)candle.Low, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness + outlineThickness, (float)candle.Low, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
//outline of the low line
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness - outlineThickness, min, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness + outlineThickness, min, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness - outlineThickness, (float)candle.Low, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness + outlineThickness, (float)candle.Low, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
//outline of the low line connection with body
v.position = new Vector3(mid - thickness - outlineThickness, min + outlineThickness, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, min + outlineThickness, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid - thickness - outlineThickness, min - outlineThickness, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, min - outlineThickness, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
//outline of the low line connection with body
v.position = new Vector3(mid + thickness + outlineThickness, min + outlineThickness, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, min + outlineThickness, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid + thickness + outlineThickness, min - outlineThickness, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, min - outlineThickness, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
//outline of the high line connection with body
v.position = new Vector3(mid - thickness - outlineThickness, max - outlineThickness, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, max - outlineThickness, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid - thickness - outlineThickness, max + outlineThickness, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, max + outlineThickness, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
//outline of the high line connection with body
v.position = new Vector3(mid + thickness + outlineThickness, max - outlineThickness, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, max - outlineThickness, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid + thickness + outlineThickness, max + outlineThickness, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, max + outlineThickness, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
}
}
IEnumerable<UIVertex> getCandle()
{
UIVertex v = new UIVertex();
if (mCandles == null)
yield break;
for (int i = 0; i < mCandles.Count; i++)
{
CandleChartData.CandleValue candle = mCandles[i];
float max = (float)Math.Max(candle.Open, candle.Close);
float min = (float)Math.Min(candle.Open, candle.Close);
float start = (float)candle.Start;
float end = (float)(candle.Start + candle.Duration);
float mid = (start + end) * 0.5f;
float thickness = (float)(mCandleSettings.CandleThicknessMultiplier * candle.Duration * 0.5);
v.position = new Vector3(mid - thickness, max, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid + thickness, max, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid - thickness, min, 0f);
v.uv0 = new Vector2(-0f, 1f);
yield return v;
v.position = new Vector3(mid + thickness, min, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
}
}
IEnumerable<UIVertex> getLine()
{
UIVertex v = new UIVertex();
if (mCandles == null)
yield break;
for (int i = 0; i < mCandles.Count; i++)
{
CandleChartData.CandleValue candle = mCandles[i];
float max = (float)Math.Max(candle.Open, candle.Close);
float min = (float)Math.Min(candle.Open, candle.Close);
float start = (float)candle.Start;
float end = (float)(candle.Start + candle.Duration);
float mid = (start + end) * 0.5f;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, (float)candle.High, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, (float)candle.High, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, max, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, max, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, min, 0f);
v.uv0 = new Vector2(0f, 0f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, min, 0f);
v.uv0 = new Vector2(1f, 0f);
yield return v;
v.position = new Vector3(mid - (float)mCandleSettings.LineThickness, (float)candle.Low, 0f);
v.uv0 = new Vector2(0f, 1f);
yield return v;
v.position = new Vector3(mid + (float)mCandleSettings.LineThickness, (float)candle.Low, 0f);
v.uv0 = new Vector2(1f, 1f);
yield return v;
}
}
IEnumerable<UIVertex> getVerices()
{
if (mCandles == null)
return new UIVertex[0];
if (mPart == 0)
return getCandle();
else if (mPart == 1)
return getLine();
return getOutline();
}
#if (!UNITY_5_2_0) && (!UNITY_5_2_1)
protected override void OnPopulateMesh(VertexHelper vh)
{
base.OnPopulateMesh(vh);
vh.Clear();
int vPos = 0;
foreach (UIVertex v in getVerices())
{
mTmpVerts[vPos++] = v;
if (vPos == 4)
{
UIVertex tmp = mTmpVerts[2];
mTmpVerts[2] = mTmpVerts[3];
mTmpVerts[3] = tmp;
vPos = 0;
vh.AddUIVertexQuad(mTmpVerts);
}
}
}
#endif
#pragma warning disable 0672
#if !UNITY_2017_1_OR_NEWER
protected override void OnPopulateMesh(Mesh m)
{
WorldSpaceChartMesh mesh = new WorldSpaceChartMesh(1);
int vPos = 0;
foreach (UIVertex v in getVerices())
{
mTmpVerts[vPos++] = v;
if (vPos == 4)
{
vPos = 0;
mesh.AddQuad(mTmpVerts[0], mTmpVerts[1], mTmpVerts[2], mTmpVerts[3]);
}
}
mesh.ApplyToMesh(m);
}
#endif
#pragma warning restore 0672
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 05af876f1131be94d999a98f574aa820
timeCreated: 1491155958
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,15 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace ChartAndGraph
{
interface ICandleCreator
{
void Generate(CandleChart parent, Rect viewRect, IList<CandleChartData.CandleValue> value, CandleChartData.CandleSettings settings);
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: dc37318de0ced4249a4f86d43c9799cc
timeCreated: 1491395378
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,27 +0,0 @@
#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ChartAndGraph
{
interface IInternalCandleData
{
/// <summary>
///
/// </summary>
/// <param name="axis">0 for horizontal 1 for vertical</param>
/// <returns></returns>
double GetMinValue(int axis, bool dataValue);
double GetMaxValue(int axis, bool dataValue);
void OnBeforeSerialize();
void OnAfterDeserialize();
event EventHandler InternalDataChanged;
event EventHandler InternalViewPortionChanged;
event Action<int,string> InternalRealTimeDataChanged;
int TotalCategories { get; }
IEnumerable<CandleChartData.CategoryData> Categories { get; }
}
}

Some files were not shown because too many files have changed in this diff Show More