mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-31 13:58:48 +00:00
BIN
Documentation~/zh/img/inputsystem01.png
Normal file
BIN
Documentation~/zh/img/inputsystem01.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
BIN
Documentation~/zh/img/inputsystem02.png
Normal file
BIN
Documentation~/zh/img/inputsystem02.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
BIN
Documentation~/zh/img/inputsystem03.png
Normal file
BIN
Documentation~/zh/img/inputsystem03.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
17
Documentation~/zh/inputsystem.md
Normal file
17
Documentation~/zh/inputsystem.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: 入门教程:从 Input Manager 转到 Input System
|
||||||
|
sidebar_position: 1
|
||||||
|
slug: /inputsystem
|
||||||
|
---
|
||||||
|
|
||||||
|
# 教程:从 Input Manager 转到 Input System
|
||||||
|
|
||||||
|
## 1. 按图示修改项目配置中输入模式为 Input System
|
||||||
|

|
||||||
|
|
||||||
|
## 2. 使用 Unity Package Manager 安装 Input System
|
||||||
|

|
||||||
|
## 3. 选中场景中 EventSystem 游戏对象,更换输入模组
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
@@ -1,8 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using XCharts.Runtime;
|
using XCharts.Runtime;
|
||||||
|
using ADB = UnityEditor.AssetDatabase;
|
||||||
|
|
||||||
|
|
||||||
namespace XCharts.Editor
|
namespace XCharts.Editor
|
||||||
{
|
{
|
||||||
@@ -22,7 +28,7 @@ namespace XCharts.Editor
|
|||||||
canvas = canvasObject.AddComponent<Canvas>();
|
canvas = canvasObject.AddComponent<Canvas>();
|
||||||
canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
||||||
var mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
|
var mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
|
||||||
canvas.worldCamera = mainCamera == null? null : mainCamera.GetComponent<Camera>();
|
canvas.worldCamera = mainCamera == null ? null : mainCamera.GetComponent<Camera>();
|
||||||
canvasObject.AddComponent<CanvasScaler>();
|
canvasObject.AddComponent<CanvasScaler>();
|
||||||
canvasObject.AddComponent<GraphicRaycaster>();
|
canvasObject.AddComponent<GraphicRaycaster>();
|
||||||
if (GameObject.Find("EventSystem") == null)
|
if (GameObject.Find("EventSystem") == null)
|
||||||
@@ -188,23 +194,155 @@ namespace XCharts.Editor
|
|||||||
XCThemeMgr.ReloadThemeList();
|
XCThemeMgr.ReloadThemeList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Text mesh pro support
|
||||||
|
#if UNITY_2017_1_OR_NEWER
|
||||||
|
const string SYMBOL_TMP = "dUI_TextMeshPro";
|
||||||
|
const string ASMDEF_TMP = "Unity.TextMeshPro";
|
||||||
|
|
||||||
[MenuItem("XCharts/TextMeshPro Enable")]
|
[MenuItem("XCharts/TextMeshPro Enable")]
|
||||||
public static void EnableTextMeshPro()
|
public static void EnableTextMeshPro()
|
||||||
{
|
{
|
||||||
if (!XChartsMgr.IsExistTMPAssembly())
|
if (!IsSpecifyAssemblyExist(ASMDEF_TMP))
|
||||||
{
|
{
|
||||||
Debug.LogError("TextMeshPro is not in the project, please import TextMeshPro package first.");
|
Debug.LogError("TextMeshPro is not in the project, please import TextMeshPro package first.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XChartsMgr.EnableTextMeshPro();
|
DefineSymbolsUtil.AddGlobalDefine(SYMBOL_TMP);
|
||||||
XChartsMgr.ModifyTMPRefence();
|
XChartsMgr.RemoveAllChartObject();
|
||||||
|
InsertSpecifyReferenceIntoAssembly(Platform.Editor, ASMDEF_TMP);
|
||||||
|
InsertSpecifyReferenceIntoAssembly(Platform.Runtime, ASMDEF_TMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("XCharts/TextMeshPro Disable")]
|
[MenuItem("XCharts/TextMeshPro Disable")]
|
||||||
public static void DisableTextMeshPro()
|
public static void DisableTextMeshPro()
|
||||||
{
|
{
|
||||||
XChartsMgr.ModifyTMPRefence(true);
|
RemoveSpecifyReferenceFromAssembly(Platform.Editor, ASMDEF_TMP);
|
||||||
XChartsMgr.DisableTextMeshPro();
|
RemoveSpecifyReferenceFromAssembly(Platform.Runtime, ASMDEF_TMP);
|
||||||
|
DefineSymbolsUtil.RemoveGlobalDefine(SYMBOL_TMP);
|
||||||
|
XChartsMgr.RemoveAllChartObject();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region InputSystem Support
|
||||||
|
#if UNITY_2019_1_OR_NEWER
|
||||||
|
//As InputSystem is released in 2019.1+ ,when unity version is 2019.1+ , enable InputSystem Support
|
||||||
|
const string SYMBOL_I_S = "INPUT_SYSTEM_ENABLED";
|
||||||
|
const string ASMDEF_I_S = "Unity.InputSystem";
|
||||||
|
[MenuItem("XCharts/InputSystem Enable")]
|
||||||
|
public static void EnableInputSystem()
|
||||||
|
{
|
||||||
|
if (!IsSpecifyAssemblyExist(ASMDEF_I_S))
|
||||||
|
{
|
||||||
|
Debug.LogError("InputSystem is not in the project, please import InputSystem package first.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// insert input system package into editor and runtime assembly
|
||||||
|
InsertSpecifyReferenceIntoAssembly(Platform.Editor, ASMDEF_I_S);
|
||||||
|
InsertSpecifyReferenceIntoAssembly(Platform.Runtime, ASMDEF_I_S);
|
||||||
|
// add scripting define symbols
|
||||||
|
DefineSymbolsUtil.AddGlobalDefine(SYMBOL_I_S);
|
||||||
|
}
|
||||||
|
[MenuItem("XCharts/InputSystem Disable")]
|
||||||
|
public static void DisableInputSystem()
|
||||||
|
{
|
||||||
|
// remove input system package into editor and runtime assembly
|
||||||
|
RemoveSpecifyReferenceFromAssembly(Platform.Editor, ASMDEF_I_S);
|
||||||
|
RemoveSpecifyReferenceFromAssembly(Platform.Runtime, ASMDEF_I_S);
|
||||||
|
// remove scripting define symbols
|
||||||
|
DefineSymbolsUtil.RemoveGlobalDefine(SYMBOL_I_S);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Assistant members
|
||||||
|
#if UNITY_2017_1_OR_NEWER
|
||||||
|
// as text mesh pro is released in 2017.1, so we may use these function and types in 2017.1 or later
|
||||||
|
private static void InsertSpecifyReferenceIntoAssembly(Platform platform, string reference)
|
||||||
|
{
|
||||||
|
var file = GetPackageAssemblyDefinitionPath(platform);
|
||||||
|
var content = File.ReadAllText(file);
|
||||||
|
var data = new AssemblyDefinitionData();
|
||||||
|
EditorJsonUtility.FromJsonOverwrite(content, data);
|
||||||
|
if (!data.references.Contains(reference))
|
||||||
|
{
|
||||||
|
data.references.Add(reference);
|
||||||
|
var json = EditorJsonUtility.ToJson(data, true);
|
||||||
|
File.WriteAllText(file, json);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RemoveSpecifyReferenceFromAssembly(Platform platform, string reference)
|
||||||
|
{
|
||||||
|
var file = GetPackageAssemblyDefinitionPath(platform);
|
||||||
|
var content = File.ReadAllText(file);
|
||||||
|
var data = new AssemblyDefinitionData();
|
||||||
|
EditorJsonUtility.FromJsonOverwrite(content, data);
|
||||||
|
if (data.references.Contains(reference))
|
||||||
|
{
|
||||||
|
data.references.Remove(reference);
|
||||||
|
var json = EditorJsonUtility.ToJson(data, true);
|
||||||
|
File.WriteAllText(file, json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Platform { Editor, Runtime }
|
||||||
|
public static string GetPackageAssemblyDefinitionPath(Platform platform)
|
||||||
|
{
|
||||||
|
var p = platform == Platform.Editor ? "Editor" : "Runtime";
|
||||||
|
var f = "XCharts." + p + ".asmdef";
|
||||||
|
var sub = Path.Combine(p, f);
|
||||||
|
string packagePath = Path.GetFullPath("Packages/com.monitor1394.xcharts");
|
||||||
|
if (!Directory.Exists(packagePath))
|
||||||
|
{
|
||||||
|
packagePath = ADB.FindAssets("t:Script")
|
||||||
|
.Where(v => Path.GetFileNameWithoutExtension(ADB.GUIDToAssetPath(v)) == "XChartsMgr")
|
||||||
|
.Select(id => ADB.GUIDToAssetPath(id))
|
||||||
|
.FirstOrDefault();
|
||||||
|
packagePath = Path.GetDirectoryName(packagePath);
|
||||||
|
packagePath = packagePath.Substring(0, packagePath.LastIndexOf("Runtime"));
|
||||||
|
}
|
||||||
|
return Path.Combine(packagePath, sub);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsSpecifyAssemblyExist(string name)
|
||||||
|
{
|
||||||
|
#if UNITY_2018_1_OR_NEWER
|
||||||
|
foreach (var assembly in UnityEditor.Compilation.CompilationPipeline.GetAssemblies(UnityEditor.Compilation.AssembliesType.Player))
|
||||||
|
{
|
||||||
|
if (assembly.name.Equals(name)) return true;
|
||||||
|
}
|
||||||
|
#elif UNITY_2017_3_OR_NEWER
|
||||||
|
foreach (var assembly in UnityEditor.Compilation.CompilationPipeline.GetAssemblies())
|
||||||
|
{
|
||||||
|
if (assembly.name.Equals(name)) return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
class AssemblyDefinitionData
|
||||||
|
{
|
||||||
|
#pragma warning disable 649
|
||||||
|
public string name;
|
||||||
|
public List<string> references;
|
||||||
|
public List<string> includePlatforms;
|
||||||
|
public List<string> excludePlatforms;
|
||||||
|
public bool allowUnsafeCode;
|
||||||
|
public bool overrideReferences;
|
||||||
|
public List<string> precompiledReferences;
|
||||||
|
public bool autoReferenced;
|
||||||
|
public List<string> defineConstraints;
|
||||||
|
public List<string> versionDefines;
|
||||||
|
public bool noEngineReferences;
|
||||||
|
#pragma warning restore 649
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,42 +11,33 @@ namespace XCharts.Example
|
|||||||
private LineChart chart;
|
private LineChart chart;
|
||||||
private float speed = 100f;
|
private float speed = 100f;
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
LoopDemo();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
LoopDemo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoopDemo()
|
|
||||||
{
|
|
||||||
StopAllCoroutines();
|
|
||||||
StartCoroutine(CheatSheet());
|
StartCoroutine(CheatSheet());
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator CheatSheet()
|
IEnumerator CheatSheet()
|
||||||
{
|
{
|
||||||
StartCoroutine(InitChart());
|
StartCoroutine(InitChart());
|
||||||
StartCoroutine(ComponentTitle());
|
while (true)
|
||||||
yield return new WaitForSeconds(2);
|
{
|
||||||
StartCoroutine(ComponentAxis());
|
StartCoroutine(ComponentTitle());
|
||||||
yield return new WaitForSeconds(2);
|
yield return new WaitForSeconds(2);
|
||||||
StartCoroutine(ComponentGrid());
|
StartCoroutine(ComponentAxis());
|
||||||
yield return new WaitForSeconds(2);
|
yield return new WaitForSeconds(2);
|
||||||
StartCoroutine(ComponentSerie());
|
StartCoroutine(ComponentGrid());
|
||||||
yield return new WaitForSeconds(4);
|
yield return new WaitForSeconds(2);
|
||||||
StartCoroutine(ComponentLegend());
|
StartCoroutine(ComponentSerie());
|
||||||
yield return new WaitForSeconds(4);
|
yield return new WaitForSeconds(4);
|
||||||
StartCoroutine(ComponentTheme());
|
StartCoroutine(ComponentLegend());
|
||||||
yield return new WaitForSeconds(4);
|
yield return new WaitForSeconds(4);
|
||||||
StartCoroutine(ComponentDataZoom());
|
StartCoroutine(ComponentTheme());
|
||||||
yield return new WaitForSeconds(5);
|
yield return new WaitForSeconds(4);
|
||||||
StartCoroutine(ComponentVisualMap());
|
StartCoroutine(ComponentDataZoom());
|
||||||
yield return new WaitForSeconds(3);
|
yield return new WaitForSeconds(5);
|
||||||
LoopDemo();
|
StartCoroutine(ComponentVisualMap());
|
||||||
|
yield return new WaitForSeconds(3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator InitChart()
|
IEnumerator InitChart()
|
||||||
@@ -54,8 +45,8 @@ namespace XCharts.Example
|
|||||||
chart = gameObject.GetComponent<LineChart>();
|
chart = gameObject.GetComponent<LineChart>();
|
||||||
if (chart == null) gameObject.AddComponent<LineChart>();
|
if (chart == null) gameObject.AddComponent<LineChart>();
|
||||||
|
|
||||||
chart.GetChartComponent<Title>().show = true;
|
chart.GetOrAddChartComponent<Title>().show = true;
|
||||||
chart.GetChartComponent<Title>().text = "术语解析-组件";
|
chart.EnsureChartComponent<Title>().text = "术语解析-组件";
|
||||||
|
|
||||||
var grid = chart.GetOrAddChartComponent<GridCoord>();
|
var grid = chart.GetOrAddChartComponent<GridCoord>();
|
||||||
grid.bottom = 30;
|
grid.bottom = 30;
|
||||||
@@ -81,31 +72,31 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator ComponentTitle()
|
IEnumerator ComponentTitle()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().text = "术语解析 - 组件";
|
chart.EnsureChartComponent<Title>().text = "术语解析 - 组件";
|
||||||
chart.GetChartComponent<Title>().subText = "Title 标题:可指定主标题和子标题";
|
chart.EnsureChartComponent<Title>().subText = "Title 标题:可指定主标题和子标题";
|
||||||
chart.GetChartComponent<XAxis>().show = true;
|
chart.EnsureChartComponent<XAxis>().show = true;
|
||||||
chart.GetChartComponent<YAxis>().show = true;
|
chart.EnsureChartComponent<YAxis>().show = true;
|
||||||
chart.GetChartComponent<Legend>().show = false;
|
chart.EnsureChartComponent<Legend>().show = false;
|
||||||
chart.series[0].show = false;
|
chart.series[0].show = false;
|
||||||
chart.series[1].show = false;
|
chart.series[1].show = false;
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().show = !chart.GetChartComponent<Title>().show;
|
chart.EnsureChartComponent<Title>().show = !chart.EnsureChartComponent<Title>().show;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
yield return new WaitForSeconds(0.2f);
|
yield return new WaitForSeconds(0.2f);
|
||||||
}
|
}
|
||||||
chart.GetChartComponent<Title>().show = true;
|
chart.EnsureChartComponent<Title>().show = true;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator ComponentAxis()
|
IEnumerator ComponentAxis()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "Axis 坐标轴:配置X和Y轴的轴线、刻度、标签等样式外观配置";
|
chart.EnsureChartComponent<Title>().subText = "Axis 坐标轴:配置X和Y轴的轴线、刻度、标签等样式外观配置";
|
||||||
chart.series[0].show = false;
|
chart.series[0].show = false;
|
||||||
chart.series[1].show = false;
|
chart.series[1].show = false;
|
||||||
var xAxis = chart.GetChartComponent<XAxis>();
|
var xAxis = chart.EnsureChartComponent<XAxis>();
|
||||||
var yAxis = chart.GetChartComponent<YAxis>();
|
var yAxis = chart.EnsureChartComponent<YAxis>();
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
xAxis.show = !xAxis.show;
|
xAxis.show = !xAxis.show;
|
||||||
@@ -121,8 +112,8 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator ComponentGrid()
|
IEnumerator ComponentGrid()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "Grid 网格:调整坐标系边距和颜色等";
|
chart.EnsureChartComponent<Title>().subText = "Grid 网格:调整坐标系边距和颜色等";
|
||||||
var grid = chart.GetChartComponent<GridCoord>();
|
var grid = chart.EnsureChartComponent<GridCoord>();
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
grid.backgroundColor = i % 2 == 0 ? Color.clear : Color.grey;
|
grid.backgroundColor = i % 2 == 0 ? Color.clear : Color.grey;
|
||||||
@@ -136,7 +127,7 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator ComponentSerie()
|
IEnumerator ComponentSerie()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "Serie 系列:调整坐标系边距和颜色等";
|
chart.EnsureChartComponent<Title>().subText = "Serie 系列:调整坐标系边距和颜色等";
|
||||||
chart.series[0].show = true;
|
chart.series[0].show = true;
|
||||||
chart.series[1].show = true;
|
chart.series[1].show = true;
|
||||||
chart.AnimationReset();
|
chart.AnimationReset();
|
||||||
@@ -157,10 +148,10 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator ComponentLegend()
|
IEnumerator ComponentLegend()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "Legend 图例:展示不同系列的名字和颜色,可控制系列显示等";
|
chart.EnsureChartComponent<Title>().subText = "Legend 图例:展示不同系列的名字和颜色,可控制系列显示等";
|
||||||
var legend = chart.GetChartComponent<Legend>();
|
var legend = chart.EnsureChartComponent<Legend>();
|
||||||
legend.show = true;
|
legend.show = true;
|
||||||
var grid = chart.GetChartComponent<GridCoord>();
|
var grid = chart.EnsureChartComponent<GridCoord>();
|
||||||
grid.top = 80;
|
grid.top = 80;
|
||||||
legend.location.top = 50;
|
legend.location.top = 50;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
@@ -187,23 +178,23 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator ComponentTheme()
|
IEnumerator ComponentTheme()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "Theme 主题:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
|
chart.EnsureChartComponent<Title>().subText = "Theme 主题:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
|
||||||
yield return new WaitForSeconds(1f);
|
yield return new WaitForSeconds(1f);
|
||||||
chart.GetChartComponent<Title>().subText = "Theme 主题:Light主题";
|
chart.EnsureChartComponent<Title>().subText = "Theme 主题:Light主题";
|
||||||
chart.UpdateTheme(ThemeType.Light);
|
chart.UpdateTheme(ThemeType.Light);
|
||||||
yield return new WaitForSeconds(1f);
|
yield return new WaitForSeconds(1f);
|
||||||
chart.GetChartComponent<Title>().subText = "Theme 主题:Dark主题";
|
chart.EnsureChartComponent<Title>().subText = "Theme 主题:Dark主题";
|
||||||
chart.UpdateTheme(ThemeType.Dark);
|
chart.UpdateTheme(ThemeType.Dark);
|
||||||
yield return new WaitForSeconds(1f);
|
yield return new WaitForSeconds(1f);
|
||||||
chart.GetChartComponent<Title>().subText = "Theme 主题:Default主题";
|
chart.EnsureChartComponent<Title>().subText = "Theme 主题:Default主题";
|
||||||
chart.UpdateTheme(ThemeType.Default);
|
chart.UpdateTheme(ThemeType.Default);
|
||||||
yield return new WaitForSeconds(1f);
|
yield return new WaitForSeconds(1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator ComponentDataZoom()
|
IEnumerator ComponentDataZoom()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "DataZoom 区域缩放:可通过拖、拽、缩小、放大来观察细节数据";
|
chart.EnsureChartComponent<Title>().subText = "DataZoom 区域缩放:可通过拖、拽、缩小、放大来观察细节数据";
|
||||||
var grid = chart.GetChartComponent<GridCoord>();
|
var grid = chart.EnsureChartComponent<GridCoord>();
|
||||||
grid.bottom = 70;
|
grid.bottom = 70;
|
||||||
|
|
||||||
var dataZoom = chart.GetOrAddChartComponent<DataZoom>();
|
var dataZoom = chart.GetOrAddChartComponent<DataZoom>();
|
||||||
@@ -265,7 +256,7 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator ComponentVisualMap()
|
IEnumerator ComponentVisualMap()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "VisualMap 视觉映射:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
|
chart.EnsureChartComponent<Title>().subText = "VisualMap 视觉映射:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
|
||||||
|
|
||||||
var visualMap = chart.GetOrAddChartComponent<VisualMap>();
|
var visualMap = chart.GetOrAddChartComponent<VisualMap>();
|
||||||
visualMap.show = true;
|
visualMap.show = true;
|
||||||
@@ -292,7 +283,7 @@ namespace XCharts.Example
|
|||||||
"#a50026"
|
"#a50026"
|
||||||
};
|
};
|
||||||
visualMap.AddColors(colors);
|
visualMap.AddColors(colors);
|
||||||
var grid = chart.GetChartComponent<GridCoord>();
|
var grid = chart.EnsureChartComponent<GridCoord>();
|
||||||
grid.left = 80;
|
grid.left = 80;
|
||||||
grid.bottom = 100;
|
grid.bottom = 100;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
|
|||||||
@@ -11,39 +11,30 @@ namespace XCharts.Example
|
|||||||
private Serie serie;
|
private Serie serie;
|
||||||
private int m_DataNum = 8;
|
private int m_DataNum = 8;
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
LoopDemo();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
LoopDemo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoopDemo()
|
|
||||||
{
|
|
||||||
StopAllCoroutines();
|
|
||||||
StartCoroutine(PieDemo());
|
StartCoroutine(PieDemo());
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator PieDemo()
|
IEnumerator PieDemo()
|
||||||
{
|
{
|
||||||
StartCoroutine(AddSimpleLine());
|
while (true)
|
||||||
yield return new WaitForSeconds(2);
|
{
|
||||||
StartCoroutine(ChangeLineType());
|
StartCoroutine(AddSimpleLine());
|
||||||
yield return new WaitForSeconds(8);
|
yield return new WaitForSeconds(2);
|
||||||
StartCoroutine(LineAreaStyleSettings());
|
StartCoroutine(ChangeLineType());
|
||||||
yield return new WaitForSeconds(5);
|
yield return new WaitForSeconds(8);
|
||||||
StartCoroutine(LineArrowSettings());
|
StartCoroutine(LineAreaStyleSettings());
|
||||||
yield return new WaitForSeconds(2);
|
yield return new WaitForSeconds(5);
|
||||||
StartCoroutine(LineSymbolSettings());
|
StartCoroutine(LineArrowSettings());
|
||||||
yield return new WaitForSeconds(7);
|
yield return new WaitForSeconds(2);
|
||||||
StartCoroutine(LineLabelSettings());
|
StartCoroutine(LineSymbolSettings());
|
||||||
yield return new WaitForSeconds(3);
|
yield return new WaitForSeconds(7);
|
||||||
StartCoroutine(LineMutilSerie());
|
StartCoroutine(LineLabelSettings());
|
||||||
yield return new WaitForSeconds(5);
|
yield return new WaitForSeconds(3);
|
||||||
LoopDemo();
|
StartCoroutine(LineMutilSerie());
|
||||||
|
yield return new WaitForSeconds(5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator AddSimpleLine()
|
IEnumerator AddSimpleLine()
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using XCharts.Runtime;
|
|||||||
namespace XCharts.Example
|
namespace XCharts.Example
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[ExecuteInEditMode]
|
|
||||||
public class Example11_AddSinCurve : MonoBehaviour
|
public class Example11_AddSinCurve : MonoBehaviour
|
||||||
{
|
{
|
||||||
private float time;
|
private float time;
|
||||||
@@ -18,14 +17,14 @@ namespace XCharts.Example
|
|||||||
{
|
{
|
||||||
chart = gameObject.AddComponent<LineChart>();
|
chart = gameObject.AddComponent<LineChart>();
|
||||||
}
|
}
|
||||||
chart.GetChartComponent<Title>().show = true;
|
chart.EnsureChartComponent<Title>().show = true;
|
||||||
chart.GetChartComponent<Title>().text = "Sin Curve";
|
chart.EnsureChartComponent<Title>().text = "Sin Curve";
|
||||||
|
|
||||||
chart.GetChartComponent<Tooltip>().show = true;
|
chart.EnsureChartComponent<Tooltip>().show = true;
|
||||||
chart.GetChartComponent<Legend>().show = false;
|
chart.EnsureChartComponent<Legend>().show = false;
|
||||||
|
|
||||||
var xAxis = chart.GetChartComponent<XAxis>();
|
var xAxis = chart.EnsureChartComponent<XAxis>();
|
||||||
var yAxis = chart.GetChartComponent<YAxis>();
|
var yAxis = chart.EnsureChartComponent<YAxis>();
|
||||||
|
|
||||||
xAxis.show = true;
|
xAxis.show = true;
|
||||||
yAxis.show = true;
|
yAxis.show = true;
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
using XCharts.Runtime;
|
using XCharts.Runtime;
|
||||||
|
|
||||||
namespace XCharts.Example
|
namespace XCharts.Example
|
||||||
|
|||||||
@@ -11,48 +11,38 @@ namespace XCharts.Example
|
|||||||
private Serie serie, serie2;
|
private Serie serie, serie2;
|
||||||
private int m_DataNum = 5;
|
private int m_DataNum = 5;
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
LoopDemo();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
LoopDemo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoopDemo()
|
|
||||||
{
|
|
||||||
StopAllCoroutines();
|
|
||||||
StartCoroutine(PieDemo());
|
StartCoroutine(PieDemo());
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator PieDemo()
|
IEnumerator PieDemo()
|
||||||
{
|
{
|
||||||
StartCoroutine(AddSimpleBar());
|
while (true)
|
||||||
yield return new WaitForSeconds(2);
|
{
|
||||||
StartCoroutine(BarMutilSerie());
|
StartCoroutine(AddSimpleBar());
|
||||||
yield return new WaitForSeconds(3);
|
yield return new WaitForSeconds(2);
|
||||||
StartCoroutine(ZebraBar());
|
StartCoroutine(BarMutilSerie());
|
||||||
yield return new WaitForSeconds(3);
|
yield return new WaitForSeconds(3);
|
||||||
StartCoroutine(SameBarAndNotStack());
|
StartCoroutine(ZebraBar());
|
||||||
yield return new WaitForSeconds(3);
|
yield return new WaitForSeconds(3);
|
||||||
StartCoroutine(SameBarAndStack());
|
StartCoroutine(SameBarAndNotStack());
|
||||||
yield return new WaitForSeconds(3);
|
yield return new WaitForSeconds(3);
|
||||||
StartCoroutine(SameBarAndPercentStack());
|
StartCoroutine(SameBarAndStack());
|
||||||
yield return new WaitForSeconds(10);
|
yield return new WaitForSeconds(3);
|
||||||
|
StartCoroutine(SameBarAndPercentStack());
|
||||||
LoopDemo();
|
yield return new WaitForSeconds(10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator AddSimpleBar()
|
IEnumerator AddSimpleBar()
|
||||||
{
|
{
|
||||||
chart = gameObject.GetComponent<BarChart>();
|
chart = gameObject.GetComponent<BarChart>();
|
||||||
if (chart == null) chart = gameObject.AddComponent<BarChart>();
|
if (chart == null) chart = gameObject.AddComponent<BarChart>();
|
||||||
chart.GetChartComponent<Title>().text = "BarChart - 柱状图";
|
chart.EnsureChartComponent<Title>().text = "BarChart - 柱状图";
|
||||||
chart.GetChartComponent<Title>().subText = "普通柱状图";
|
chart.EnsureChartComponent<Title>().subText = "普通柱状图";
|
||||||
|
|
||||||
var yAxis = chart.GetChartComponent<YAxis>();
|
var yAxis = chart.EnsureChartComponent<YAxis>();
|
||||||
yAxis.minMaxType = Axis.AxisMinMaxType.Default;
|
yAxis.minMaxType = Axis.AxisMinMaxType.Default;
|
||||||
|
|
||||||
chart.RemoveData();
|
chart.RemoveData();
|
||||||
@@ -68,7 +58,7 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator BarMutilSerie()
|
IEnumerator BarMutilSerie()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "多条柱状图";
|
chart.EnsureChartComponent<Title>().subText = "多条柱状图";
|
||||||
|
|
||||||
float now = serie.barWidth - 0.35f;
|
float now = serie.barWidth - 0.35f;
|
||||||
while (serie.barWidth > 0.35f)
|
while (serie.barWidth > 0.35f)
|
||||||
@@ -90,7 +80,7 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator ZebraBar()
|
IEnumerator ZebraBar()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "斑马柱状图";
|
chart.EnsureChartComponent<Title>().subText = "斑马柱状图";
|
||||||
serie.barType = BarType.Zebra;
|
serie.barType = BarType.Zebra;
|
||||||
serie2.barType = BarType.Zebra;
|
serie2.barType = BarType.Zebra;
|
||||||
serie.barZebraWidth = serie.barZebraGap = 4;
|
serie.barZebraWidth = serie.barZebraGap = 4;
|
||||||
@@ -101,7 +91,7 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator SameBarAndNotStack()
|
IEnumerator SameBarAndNotStack()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "非堆叠同柱";
|
chart.EnsureChartComponent<Title>().subText = "非堆叠同柱";
|
||||||
serie.barType = serie2.barType = BarType.Normal;
|
serie.barType = serie2.barType = BarType.Normal;
|
||||||
serie.stack = "";
|
serie.stack = "";
|
||||||
serie2.stack = "";
|
serie2.stack = "";
|
||||||
@@ -112,7 +102,7 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator SameBarAndStack()
|
IEnumerator SameBarAndStack()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "堆叠同柱";
|
chart.EnsureChartComponent<Title>().subText = "堆叠同柱";
|
||||||
serie.barType = serie2.barType = BarType.Normal;
|
serie.barType = serie2.barType = BarType.Normal;
|
||||||
serie.stack = "samename";
|
serie.stack = "samename";
|
||||||
serie2.stack = "samename";
|
serie2.stack = "samename";
|
||||||
@@ -132,19 +122,25 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator SameBarAndPercentStack()
|
IEnumerator SameBarAndPercentStack()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "百分比堆叠同柱";
|
chart.EnsureChartComponent<Title>().subText = "百分比堆叠同柱";
|
||||||
serie.barType = serie2.barType = BarType.Normal;
|
serie.barType = serie2.barType = BarType.Normal;
|
||||||
serie.stack = "samename";
|
serie.stack = "samename";
|
||||||
serie2.stack = "samename";
|
serie2.stack = "samename";
|
||||||
|
|
||||||
serie.barPercentStack = true;
|
serie.barPercentStack = true;
|
||||||
|
if (null == serie.label)
|
||||||
serie.AddExtraComponent<LabelStyle>();
|
{
|
||||||
|
serie.AddExtraComponent<LabelStyle>();
|
||||||
|
}
|
||||||
serie.label.show = true;
|
serie.label.show = true;
|
||||||
serie.label.position = LabelStyle.Position.Center;
|
serie.label.position = LabelStyle.Position.Center;
|
||||||
serie.label.textStyle.color = Color.white;
|
serie.label.textStyle.color = Color.white;
|
||||||
serie.label.formatter = "{d:f0}%";
|
serie.label.formatter = "{d:f0}%";
|
||||||
|
|
||||||
|
if (null == serie2.label)
|
||||||
|
{
|
||||||
|
serie2.AddExtraComponent<LabelStyle>();
|
||||||
|
}
|
||||||
serie2.label.show = true;
|
serie2.label.show = true;
|
||||||
serie2.label.position = LabelStyle.Position.Center;
|
serie2.label.position = LabelStyle.Position.Center;
|
||||||
serie2.label.textStyle.color = Color.white;
|
serie2.label.textStyle.color = Color.white;
|
||||||
|
|||||||
@@ -13,45 +13,37 @@ namespace XCharts.Example
|
|||||||
private float m_RadiusSpeed = 100f;
|
private float m_RadiusSpeed = 100f;
|
||||||
private float m_CenterSpeed = 1f;
|
private float m_CenterSpeed = 1f;
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
LoopDemo();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
LoopDemo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoopDemo()
|
|
||||||
{
|
|
||||||
StopAllCoroutines();
|
|
||||||
StartCoroutine(PieDemo());
|
StartCoroutine(PieDemo());
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator PieDemo()
|
IEnumerator PieDemo()
|
||||||
{
|
{
|
||||||
StartCoroutine(PieAdd());
|
while (true)
|
||||||
yield return new WaitForSeconds(2);
|
{
|
||||||
StartCoroutine(PieShowLabel());
|
StartCoroutine(PieAdd());
|
||||||
yield return new WaitForSeconds(4);
|
yield return new WaitForSeconds(2);
|
||||||
StartCoroutine(Doughnut());
|
StartCoroutine(PieShowLabel());
|
||||||
yield return new WaitForSeconds(3);
|
yield return new WaitForSeconds(4);
|
||||||
StartCoroutine(DoublePie());
|
StartCoroutine(Doughnut());
|
||||||
yield return new WaitForSeconds(2);
|
yield return new WaitForSeconds(3);
|
||||||
StartCoroutine(RosePie());
|
StartCoroutine(DoublePie());
|
||||||
yield return new WaitForSeconds(5);
|
yield return new WaitForSeconds(2);
|
||||||
LoopDemo();
|
StartCoroutine(RosePie());
|
||||||
|
yield return new WaitForSeconds(5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator PieAdd()
|
IEnumerator PieAdd()
|
||||||
{
|
{
|
||||||
chart = gameObject.GetComponent<PieChart>();
|
chart = gameObject.GetComponent<PieChart>();
|
||||||
if (chart == null) chart = gameObject.AddComponent<PieChart>();
|
if (chart == null) chart = gameObject.AddComponent<PieChart>();
|
||||||
|
yield return null;
|
||||||
chart.GetChartComponent<Title>().text = "PieChart - 饼图";
|
chart.GetChartComponent<Title>().text = "PieChart - 饼图";
|
||||||
chart.GetChartComponent<Title>().subText = "基础饼图";
|
chart.GetChartComponent<Title>().subText = "基础饼图";
|
||||||
|
|
||||||
var legend = chart.GetChartComponent<Legend>();
|
var legend = chart.EnsureChartComponent<Legend>();
|
||||||
legend.show = true;
|
legend.show = true;
|
||||||
legend.location.align = Location.Align.TopLeft;
|
legend.location.align = Location.Align.TopLeft;
|
||||||
legend.location.top = 60;
|
legend.location.top = 60;
|
||||||
@@ -72,7 +64,7 @@ namespace XCharts.Example
|
|||||||
chart.AddData(0, 135, "视频广告");
|
chart.AddData(0, 135, "视频广告");
|
||||||
chart.AddData(0, 1548, "搜索引擎");
|
chart.AddData(0, 1548, "搜索引擎");
|
||||||
|
|
||||||
chart.onPointerClickPie = delegate(PointerEventData e, int serieIndex, int dataIndex)
|
chart.onPointerClickPie = delegate (PointerEventData e, int serieIndex, int dataIndex)
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -81,7 +73,7 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator PieShowLabel()
|
IEnumerator PieShowLabel()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "显示文本标签";
|
chart.EnsureChartComponent<Title>().subText = "显示文本标签";
|
||||||
|
|
||||||
serie.AddExtraComponent<LabelStyle>();
|
serie.AddExtraComponent<LabelStyle>();
|
||||||
serie.label.show = true;
|
serie.label.show = true;
|
||||||
@@ -105,7 +97,7 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator Doughnut()
|
IEnumerator Doughnut()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "圆环图";
|
chart.EnsureChartComponent<Title>().subText = "圆环图";
|
||||||
serie.radius[0] = 2f;
|
serie.radius[0] = 2f;
|
||||||
while (serie.radius[0] < serie.radius[1] * 0.7f)
|
while (serie.radius[0] < serie.radius[1] * 0.7f)
|
||||||
{
|
{
|
||||||
@@ -129,8 +121,7 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator DoublePie()
|
IEnumerator DoublePie()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "多图组合";
|
chart.EnsureChartComponent<Title>().subText = "多图组合";
|
||||||
|
|
||||||
serie1 = chart.AddSerie<Pie>("访问来源2");
|
serie1 = chart.AddSerie<Pie>("访问来源2");
|
||||||
chart.AddData(1, 335, "直达");
|
chart.AddData(1, 335, "直达");
|
||||||
chart.AddData(1, 679, "营销广告");
|
chart.AddData(1, 679, "营销广告");
|
||||||
@@ -146,7 +137,14 @@ namespace XCharts.Example
|
|||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
|
if (null == serie.label)
|
||||||
|
{
|
||||||
|
serie.AddExtraComponent<LabelStyle>();
|
||||||
|
}
|
||||||
|
if (null == serie1.label)
|
||||||
|
{
|
||||||
|
serie1.AddExtraComponent<LabelStyle>();
|
||||||
|
}
|
||||||
serie1.label.show = true;
|
serie1.label.show = true;
|
||||||
serie1.label.position = LabelStyle.Position.Inside;
|
serie1.label.position = LabelStyle.Position.Inside;
|
||||||
serie1.label.textStyle.color = Color.white;
|
serie1.label.textStyle.color = Color.white;
|
||||||
@@ -158,8 +156,8 @@ namespace XCharts.Example
|
|||||||
|
|
||||||
IEnumerator RosePie()
|
IEnumerator RosePie()
|
||||||
{
|
{
|
||||||
chart.GetChartComponent<Title>().subText = "玫瑰图";
|
chart.EnsureChartComponent<Title>().subText = "玫瑰图";
|
||||||
chart.GetChartComponent<Legend>().show = false;
|
chart.EnsureChartComponent<Legend>().show = false;
|
||||||
serie1.ClearData();
|
serie1.ClearData();
|
||||||
serie.ClearData();
|
serie.ClearData();
|
||||||
serie1.radius = serie.radius = new float[2] { 0, 80 };
|
serie1.radius = serie.radius = new float[2] { 0, 80 };
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using XCharts.Runtime;
|
using XCharts.Runtime;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
namespace XCharts.Example
|
namespace XCharts.Example
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using XCharts.Runtime;
|
using XCharts.Runtime;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
namespace XCharts.Example
|
namespace XCharts.Example
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using XCharts.Runtime;
|
using XCharts.Runtime;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
namespace XCharts.Example
|
namespace XCharts.Example
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using XCharts.Runtime;
|
using XCharts.Runtime;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
namespace XCharts.Example
|
namespace XCharts.Example
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
@@ -18,7 +20,7 @@ namespace XCharts.Example
|
|||||||
{
|
{
|
||||||
chart = gameObject.AddComponent<CandlestickChart>();
|
chart = gameObject.AddComponent<CandlestickChart>();
|
||||||
}
|
}
|
||||||
GenerateOHLC(dataCount);
|
AddData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
@@ -29,9 +31,7 @@ namespace XCharts.Example
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddData() { }
|
void AddData()
|
||||||
|
|
||||||
void GenerateOHLC(int count)
|
|
||||||
{
|
{
|
||||||
chart.ClearData();
|
chart.ClearData();
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ namespace XCharts.Example
|
|||||||
var boxVals = new float[4];
|
var boxVals = new float[4];
|
||||||
var dayRange = 12;
|
var dayRange = 12;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < dataCount; i++)
|
||||||
{
|
{
|
||||||
baseValue = baseValue + Random.Range(0f, 1f) * 30 - 10;
|
baseValue = baseValue + Random.Range(0f, 1f) * 30 - 10;
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++)
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using XCharts.Runtime;
|
using XCharts.Runtime;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace XCharts.Example
|
namespace XCharts.Example
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using XCharts.Runtime;
|
using XCharts.Runtime;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
namespace XCharts.Example
|
namespace XCharts.Example
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using XCharts.Runtime;
|
using XCharts.Runtime;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
namespace XCharts.Example
|
namespace XCharts.Example
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using XCharts.Runtime;
|
using XCharts.Runtime;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
namespace XCharts.Example
|
namespace XCharts.Example
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
|
|||||||
@@ -10,5 +10,6 @@
|
|||||||
"overrideReferences": false,
|
"overrideReferences": false,
|
||||||
"precompiledReferences": [],
|
"precompiledReferences": [],
|
||||||
"autoReferenced": true,
|
"autoReferenced": true,
|
||||||
"defineConstraints": []
|
"defineConstraints": [],
|
||||||
|
"versionDefines": []
|
||||||
}
|
}
|
||||||
@@ -70,6 +70,7 @@
|
|||||||
- 支持万级大数据量绘制,支持采样绘制。
|
- 支持万级大数据量绘制,支持采样绘制。
|
||||||
- 支持`TexMeshPro`。
|
- 支持`TexMeshPro`。
|
||||||
- 支持所有`5.6`以上的`Unity`版本。
|
- 支持所有`5.6`以上的`Unity`版本。
|
||||||
|
- 支持 Input System ([如何从 Input Manager 转 Input System](Documentation~/zh/inputsystem.md))。
|
||||||
|
|
||||||
## 截图
|
## 截图
|
||||||
|
|
||||||
|
|||||||
@@ -631,12 +631,12 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
internal void UpdateStartLabelPosition(Vector3 pos)
|
internal void UpdateStartLabelPosition(Vector3 pos)
|
||||||
{
|
{
|
||||||
m_StartLabel.SetPosition(pos);
|
if (m_StartLabel != null) m_StartLabel.SetPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void UpdateEndLabelPosition(Vector3 pos)
|
internal void UpdateEndLabelPosition(Vector3 pos)
|
||||||
{
|
{
|
||||||
m_EndLabel.SetPosition(pos);
|
if (m_EndLabel != null) m_EndLabel.SetPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
|
public void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using XUGL;
|
using XUGL;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace XCharts.Runtime
|
namespace XCharts.Runtime
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ using UnityEngine;
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using XUGL;
|
using XUGL;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
namespace XCharts.Runtime
|
namespace XCharts.Runtime
|
||||||
{
|
{
|
||||||
[UnityEngine.Scripting.Preserve]
|
[UnityEngine.Scripting.Preserve]
|
||||||
|
|||||||
@@ -253,6 +253,14 @@ namespace XCharts.Runtime
|
|||||||
else
|
else
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
public T EnsureChartComponent<T>() where T : MainComponent
|
||||||
|
{
|
||||||
|
var component = GetChartComponent<T>();
|
||||||
|
if (component == null)
|
||||||
|
return AddChartComponent<T>();
|
||||||
|
else
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
public bool TryGetChartComponent<T>(out T component, int index = 0)
|
public bool TryGetChartComponent<T>(out T component, int index = 0)
|
||||||
where T : MainComponent
|
where T : MainComponent
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
[AddComponentMenu("XCharts/EmptyChart", 10)]
|
[AddComponentMenu("XCharts/EmptyChart", 10)]
|
||||||
[ExecuteInEditMode]
|
[ExecuteInEditMode]
|
||||||
[RequireComponent(typeof(RectTransform))]
|
[RequireComponent(typeof(RectTransform),typeof(CanvasRenderer))]
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
public partial class BaseChart : BaseGraph, ISerializationCallbackReceiver
|
public partial class BaseChart : BaseGraph, ISerializationCallbackReceiver
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ using System;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using Input = XCharts.Runtime.InputHelper;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace XCharts.Runtime
|
namespace XCharts.Runtime
|
||||||
{
|
{
|
||||||
@@ -9,302 +12,303 @@ namespace XCharts.Runtime
|
|||||||
public partial class BaseGraph : MaskableGraphic, IPointerDownHandler, IPointerUpHandler,
|
public partial class BaseGraph : MaskableGraphic, IPointerDownHandler, IPointerUpHandler,
|
||||||
IPointerEnterHandler, IPointerExitHandler, IBeginDragHandler, IPointerClickHandler,
|
IPointerEnterHandler, IPointerExitHandler, IBeginDragHandler, IPointerClickHandler,
|
||||||
IDragHandler, IEndDragHandler, IScrollHandler
|
IDragHandler, IEndDragHandler, IScrollHandler
|
||||||
|
{
|
||||||
|
[SerializeField] protected bool m_EnableTextMeshPro = false;
|
||||||
|
|
||||||
|
protected Painter m_Painter;
|
||||||
|
protected int m_SiblingIndex;
|
||||||
|
|
||||||
|
protected float m_GraphWidth;
|
||||||
|
protected float m_GraphHeight;
|
||||||
|
protected float m_GraphX;
|
||||||
|
protected float m_GraphY;
|
||||||
|
protected Vector3 m_GraphPosition = Vector3.zero;
|
||||||
|
protected Vector2 m_GraphMinAnchor;
|
||||||
|
protected Vector2 m_GraphMaxAnchor;
|
||||||
|
protected Vector2 m_GraphPivot;
|
||||||
|
protected Vector2 m_GraphSizeDelta;
|
||||||
|
protected Vector2 m_GraphAnchoredPosition;
|
||||||
|
protected Rect m_GraphRect = new Rect(0, 0, 0, 0);
|
||||||
|
protected bool m_RefreshChart = false;
|
||||||
|
protected bool m_ForceOpenRaycastTarget;
|
||||||
|
protected bool m_IsControlledByLayout = false;
|
||||||
|
protected bool m_PainerDirty = false;
|
||||||
|
protected bool m_IsOnValidate = false;
|
||||||
|
protected Vector3 m_LastLocalPosition;
|
||||||
|
|
||||||
|
protected Action<PointerEventData, BaseGraph> m_OnPointerClick;
|
||||||
|
protected Action<PointerEventData, BaseGraph> m_OnPointerDown;
|
||||||
|
protected Action<PointerEventData, BaseGraph> m_OnPointerUp;
|
||||||
|
protected Action<PointerEventData, BaseGraph> m_OnPointerEnter;
|
||||||
|
protected Action<PointerEventData, BaseGraph> m_OnPointerExit;
|
||||||
|
protected Action<PointerEventData, BaseGraph> m_OnBeginDrag;
|
||||||
|
protected Action<PointerEventData, BaseGraph> m_OnDrag;
|
||||||
|
protected Action<PointerEventData, BaseGraph> m_OnEndDrag;
|
||||||
|
protected Action<PointerEventData, BaseGraph> m_OnScroll;
|
||||||
|
|
||||||
|
public virtual HideFlags chartHideFlags { get { return HideFlags.None; } }
|
||||||
|
|
||||||
|
private ScrollRect m_ScrollRect;
|
||||||
|
|
||||||
|
public Painter painter { get { return m_Painter; } }
|
||||||
|
|
||||||
|
protected virtual void InitComponent()
|
||||||
{
|
{
|
||||||
[SerializeField] protected bool m_EnableTextMeshPro = false;
|
InitPainter();
|
||||||
|
}
|
||||||
|
|
||||||
protected Painter m_Painter;
|
protected override void Awake()
|
||||||
protected int m_SiblingIndex;
|
{
|
||||||
|
CheckTextMeshPro();
|
||||||
|
m_SiblingIndex = 0;
|
||||||
|
m_LastLocalPosition = transform.localPosition;
|
||||||
|
UpdateSize();
|
||||||
|
InitComponent();
|
||||||
|
CheckIsInScrollRect();
|
||||||
|
}
|
||||||
|
|
||||||
protected float m_GraphWidth;
|
protected override void Start()
|
||||||
protected float m_GraphHeight;
|
{
|
||||||
protected float m_GraphX;
|
m_RefreshChart = true;
|
||||||
protected float m_GraphY;
|
}
|
||||||
protected Vector3 m_GraphPosition = Vector3.zero;
|
|
||||||
protected Vector2 m_GraphMinAnchor;
|
|
||||||
protected Vector2 m_GraphMaxAnchor;
|
|
||||||
protected Vector2 m_GraphPivot;
|
|
||||||
protected Vector2 m_GraphSizeDelta;
|
|
||||||
protected Vector2 m_GraphAnchoredPosition;
|
|
||||||
protected Rect m_GraphRect = new Rect(0, 0, 0, 0);
|
|
||||||
protected bool m_RefreshChart = false;
|
|
||||||
protected bool m_ForceOpenRaycastTarget;
|
|
||||||
protected bool m_IsControlledByLayout = false;
|
|
||||||
protected bool m_PainerDirty = false;
|
|
||||||
protected bool m_IsOnValidate = false;
|
|
||||||
protected Vector3 m_LastLocalPosition;
|
|
||||||
|
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnPointerClick;
|
protected virtual void Update()
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnPointerDown;
|
{
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnPointerUp;
|
CheckSize();
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnPointerEnter;
|
if (m_IsOnValidate)
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnPointerExit;
|
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnBeginDrag;
|
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnDrag;
|
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnEndDrag;
|
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnScroll;
|
|
||||||
|
|
||||||
public virtual HideFlags chartHideFlags { get { return HideFlags.None; } }
|
|
||||||
|
|
||||||
private ScrollRect m_ScrollRect;
|
|
||||||
|
|
||||||
public Painter painter { get { return m_Painter; } }
|
|
||||||
|
|
||||||
protected virtual void InitComponent()
|
|
||||||
{
|
|
||||||
InitPainter();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Awake()
|
|
||||||
{
|
{
|
||||||
|
m_IsOnValidate = false;
|
||||||
CheckTextMeshPro();
|
CheckTextMeshPro();
|
||||||
m_SiblingIndex = 0;
|
|
||||||
m_LastLocalPosition = transform.localPosition;
|
|
||||||
UpdateSize();
|
|
||||||
InitComponent();
|
InitComponent();
|
||||||
CheckIsInScrollRect();
|
RefreshGraph();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
protected override void Start()
|
|
||||||
{
|
{
|
||||||
m_RefreshChart = true;
|
CheckComponent();
|
||||||
}
|
}
|
||||||
|
CheckPointerPos();
|
||||||
|
CheckRefreshChart();
|
||||||
|
CheckRefreshPainter();
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void Update()
|
protected virtual void SetAllComponentDirty()
|
||||||
{
|
{
|
||||||
CheckSize();
|
|
||||||
if (m_IsOnValidate)
|
|
||||||
{
|
|
||||||
m_IsOnValidate = false;
|
|
||||||
CheckTextMeshPro();
|
|
||||||
InitComponent();
|
|
||||||
RefreshGraph();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CheckComponent();
|
|
||||||
}
|
|
||||||
CheckPointerPos();
|
|
||||||
CheckRefreshChart();
|
|
||||||
CheckRefreshPainter();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void SetAllComponentDirty()
|
|
||||||
{
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (!Application.isPlaying)
|
if (!Application.isPlaying)
|
||||||
{
|
|
||||||
m_IsOnValidate = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
m_PainerDirty = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void CheckComponent()
|
|
||||||
{
|
|
||||||
if (m_PainerDirty)
|
|
||||||
{
|
|
||||||
InitPainter();
|
|
||||||
m_PainerDirty = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckTextMeshPro()
|
|
||||||
{
|
|
||||||
#if dUI_TextMeshPro
|
|
||||||
var enableTextMeshPro = true;
|
|
||||||
#else
|
|
||||||
var enableTextMeshPro = false;
|
|
||||||
#endif
|
|
||||||
if (m_EnableTextMeshPro != enableTextMeshPro)
|
|
||||||
{
|
|
||||||
m_EnableTextMeshPro = enableTextMeshPro;
|
|
||||||
RebuildChartObject();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
protected override void Reset() { }
|
|
||||||
|
|
||||||
protected override void OnValidate()
|
|
||||||
{
|
{
|
||||||
m_IsOnValidate = true;
|
m_IsOnValidate = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
m_PainerDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnDestroy()
|
protected virtual void CheckComponent()
|
||||||
|
{
|
||||||
|
if (m_PainerDirty)
|
||||||
{
|
{
|
||||||
for (int i = transform.childCount - 1; i >= 0; i--)
|
InitPainter();
|
||||||
{
|
m_PainerDirty = false;
|
||||||
DestroyImmediate(transform.GetChild(i).gameObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnPopulateMesh(VertexHelper vh)
|
|
||||||
{
|
|
||||||
vh.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void InitPainter()
|
|
||||||
{
|
|
||||||
m_Painter = ChartHelper.AddPainterObject("painter_b", transform, m_GraphMinAnchor,
|
|
||||||
m_GraphMaxAnchor, m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight), chartHideFlags, 1);
|
|
||||||
m_Painter.type = Painter.Type.Base;
|
|
||||||
m_Painter.onPopulateMesh = OnDrawPainterBase;
|
|
||||||
m_Painter.transform.SetSiblingIndex(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckSize()
|
|
||||||
{
|
|
||||||
var currWidth = rectTransform.rect.width;
|
|
||||||
var currHeight = rectTransform.rect.height;
|
|
||||||
|
|
||||||
if (m_GraphWidth == 0 && m_GraphHeight == 0 && (currWidth != 0 || currHeight != 0))
|
|
||||||
{
|
|
||||||
Awake();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_GraphWidth != currWidth ||
|
|
||||||
m_GraphHeight != currHeight ||
|
|
||||||
m_GraphMinAnchor != rectTransform.anchorMin ||
|
|
||||||
m_GraphMaxAnchor != rectTransform.anchorMax ||
|
|
||||||
m_GraphAnchoredPosition != rectTransform.anchoredPosition)
|
|
||||||
{
|
|
||||||
UpdateSize();
|
|
||||||
}
|
|
||||||
if (!ChartHelper.IsValueEqualsVector3(m_LastLocalPosition, transform.localPosition))
|
|
||||||
{
|
|
||||||
m_LastLocalPosition = transform.localPosition;
|
|
||||||
OnLocalPositionChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void UpdateSize()
|
|
||||||
{
|
|
||||||
m_GraphWidth = rectTransform.rect.width;
|
|
||||||
m_GraphHeight = rectTransform.rect.height;
|
|
||||||
|
|
||||||
m_GraphMaxAnchor = rectTransform.anchorMax;
|
|
||||||
m_GraphMinAnchor = rectTransform.anchorMin;
|
|
||||||
m_GraphSizeDelta = rectTransform.sizeDelta;
|
|
||||||
m_GraphAnchoredPosition = rectTransform.anchoredPosition;
|
|
||||||
|
|
||||||
rectTransform.pivot = LayerHelper.ResetChartPositionAndPivot(m_GraphMinAnchor, m_GraphMaxAnchor,
|
|
||||||
m_GraphWidth, m_GraphHeight, ref m_GraphX, ref m_GraphY);
|
|
||||||
m_GraphPivot = rectTransform.pivot;
|
|
||||||
|
|
||||||
m_GraphRect.x = m_GraphX;
|
|
||||||
m_GraphRect.y = m_GraphY;
|
|
||||||
m_GraphRect.width = m_GraphWidth;
|
|
||||||
m_GraphRect.height = m_GraphHeight;
|
|
||||||
m_GraphPosition.x = m_GraphX;
|
|
||||||
m_GraphPosition.y = m_GraphY;
|
|
||||||
|
|
||||||
OnSizeChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckPointerPos()
|
|
||||||
{
|
|
||||||
if (!isPointerInChart) return;
|
|
||||||
if (canvas == null) return;
|
|
||||||
Vector2 local;
|
|
||||||
if (!ScreenPointToChartPoint(Input.mousePosition, out local))
|
|
||||||
{
|
|
||||||
pointerPos = Vector2.zero;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pointerPos = local;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void CheckIsInScrollRect()
|
|
||||||
{
|
|
||||||
m_ScrollRect = GetComponentInParent<ScrollRect>();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void CheckRefreshChart()
|
|
||||||
{
|
|
||||||
if (m_RefreshChart)
|
|
||||||
{
|
|
||||||
m_Painter.Refresh();
|
|
||||||
m_RefreshChart = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void CheckRefreshPainter()
|
|
||||||
{
|
|
||||||
m_Painter.CheckRefresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal virtual void RefreshPainter(Painter painter)
|
|
||||||
{
|
|
||||||
if (painter == null) return;
|
|
||||||
painter.Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnSizeChanged()
|
|
||||||
{
|
|
||||||
m_RefreshChart = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnLocalPositionChanged() { }
|
|
||||||
|
|
||||||
protected virtual void OnDrawPainterBase(VertexHelper vh, Painter painter)
|
|
||||||
{
|
|
||||||
DrawPainterBase(vh);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void DrawPainterBase(VertexHelper vh) { }
|
|
||||||
|
|
||||||
public virtual void OnPointerClick(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
if (m_OnPointerClick != null) m_OnPointerClick(eventData, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnPointerDown(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
if (m_OnPointerDown != null) m_OnPointerDown(eventData, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnPointerUp(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
if (m_OnPointerUp != null) m_OnPointerUp(eventData, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnPointerEnter(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
isPointerInChart = true;
|
|
||||||
if (m_OnPointerEnter != null) m_OnPointerEnter(eventData, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnPointerExit(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
isPointerInChart = false;
|
|
||||||
if (m_OnPointerExit != null) m_OnPointerExit(eventData, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnBeginDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
if (m_ScrollRect != null) m_ScrollRect.OnBeginDrag(eventData);
|
|
||||||
if (m_OnBeginDrag != null) m_OnBeginDrag(eventData, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnEndDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
if (m_ScrollRect != null) m_ScrollRect.OnEndDrag(eventData);
|
|
||||||
if (m_OnEndDrag != null) m_OnEndDrag(eventData, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
if (m_ScrollRect != null) m_ScrollRect.OnDrag(eventData);
|
|
||||||
if (m_OnDrag != null) m_OnDrag(eventData, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnScroll(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
if (m_ScrollRect != null) m_ScrollRect.OnScroll(eventData);
|
|
||||||
if (m_OnScroll != null) m_OnScroll(eventData, this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckTextMeshPro()
|
||||||
|
{
|
||||||
|
#if dUI_TextMeshPro
|
||||||
|
var enableTextMeshPro = true;
|
||||||
|
#else
|
||||||
|
var enableTextMeshPro = false;
|
||||||
|
#endif
|
||||||
|
if (m_EnableTextMeshPro != enableTextMeshPro)
|
||||||
|
{
|
||||||
|
m_EnableTextMeshPro = enableTextMeshPro;
|
||||||
|
RebuildChartObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
protected override void Reset() { }
|
||||||
|
|
||||||
|
protected override void OnValidate()
|
||||||
|
{
|
||||||
|
m_IsOnValidate = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected override void OnDestroy()
|
||||||
|
{
|
||||||
|
for (int i = transform.childCount - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
DestroyImmediate(transform.GetChild(i).gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPopulateMesh(VertexHelper vh)
|
||||||
|
{
|
||||||
|
vh.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void InitPainter()
|
||||||
|
{
|
||||||
|
m_Painter = ChartHelper.AddPainterObject("painter_b", transform, m_GraphMinAnchor,
|
||||||
|
m_GraphMaxAnchor, m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight), chartHideFlags, 1);
|
||||||
|
m_Painter.type = Painter.Type.Base;
|
||||||
|
m_Painter.onPopulateMesh = OnDrawPainterBase;
|
||||||
|
m_Painter.transform.SetSiblingIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckSize()
|
||||||
|
{
|
||||||
|
var currWidth = rectTransform.rect.width;
|
||||||
|
var currHeight = rectTransform.rect.height;
|
||||||
|
|
||||||
|
if (m_GraphWidth == 0 && m_GraphHeight == 0 && (currWidth != 0 || currHeight != 0))
|
||||||
|
{
|
||||||
|
Awake();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_GraphWidth != currWidth ||
|
||||||
|
m_GraphHeight != currHeight ||
|
||||||
|
m_GraphMinAnchor != rectTransform.anchorMin ||
|
||||||
|
m_GraphMaxAnchor != rectTransform.anchorMax ||
|
||||||
|
m_GraphAnchoredPosition != rectTransform.anchoredPosition)
|
||||||
|
{
|
||||||
|
UpdateSize();
|
||||||
|
}
|
||||||
|
if (!ChartHelper.IsValueEqualsVector3(m_LastLocalPosition, transform.localPosition))
|
||||||
|
{
|
||||||
|
m_LastLocalPosition = transform.localPosition;
|
||||||
|
OnLocalPositionChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void UpdateSize()
|
||||||
|
{
|
||||||
|
m_GraphWidth = rectTransform.rect.width;
|
||||||
|
m_GraphHeight = rectTransform.rect.height;
|
||||||
|
|
||||||
|
m_GraphMaxAnchor = rectTransform.anchorMax;
|
||||||
|
m_GraphMinAnchor = rectTransform.anchorMin;
|
||||||
|
m_GraphSizeDelta = rectTransform.sizeDelta;
|
||||||
|
m_GraphAnchoredPosition = rectTransform.anchoredPosition;
|
||||||
|
|
||||||
|
rectTransform.pivot = LayerHelper.ResetChartPositionAndPivot(m_GraphMinAnchor, m_GraphMaxAnchor,
|
||||||
|
m_GraphWidth, m_GraphHeight, ref m_GraphX, ref m_GraphY);
|
||||||
|
m_GraphPivot = rectTransform.pivot;
|
||||||
|
|
||||||
|
m_GraphRect.x = m_GraphX;
|
||||||
|
m_GraphRect.y = m_GraphY;
|
||||||
|
m_GraphRect.width = m_GraphWidth;
|
||||||
|
m_GraphRect.height = m_GraphHeight;
|
||||||
|
m_GraphPosition.x = m_GraphX;
|
||||||
|
m_GraphPosition.y = m_GraphY;
|
||||||
|
|
||||||
|
OnSizeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckPointerPos()
|
||||||
|
{
|
||||||
|
if (!isPointerInChart) return;
|
||||||
|
if (canvas == null) return;
|
||||||
|
Vector2 mousePos = Input.mousePosition;
|
||||||
|
Vector2 local;
|
||||||
|
if (!ScreenPointToChartPoint(mousePos, out local))
|
||||||
|
{
|
||||||
|
pointerPos = Vector2.zero;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pointerPos = local;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void CheckIsInScrollRect()
|
||||||
|
{
|
||||||
|
m_ScrollRect = GetComponentInParent<ScrollRect>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void CheckRefreshChart()
|
||||||
|
{
|
||||||
|
if (m_RefreshChart)
|
||||||
|
{
|
||||||
|
m_Painter.Refresh();
|
||||||
|
m_RefreshChart = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void CheckRefreshPainter()
|
||||||
|
{
|
||||||
|
m_Painter.CheckRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual void RefreshPainter(Painter painter)
|
||||||
|
{
|
||||||
|
if (painter == null) return;
|
||||||
|
painter.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnSizeChanged()
|
||||||
|
{
|
||||||
|
m_RefreshChart = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnLocalPositionChanged() { }
|
||||||
|
|
||||||
|
protected virtual void OnDrawPainterBase(VertexHelper vh, Painter painter)
|
||||||
|
{
|
||||||
|
DrawPainterBase(vh);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void DrawPainterBase(VertexHelper vh) { }
|
||||||
|
|
||||||
|
public virtual void OnPointerClick(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (m_OnPointerClick != null) m_OnPointerClick(eventData, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnPointerDown(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (m_OnPointerDown != null) m_OnPointerDown(eventData, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnPointerUp(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (m_OnPointerUp != null) m_OnPointerUp(eventData, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnPointerEnter(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
isPointerInChart = true;
|
||||||
|
if (m_OnPointerEnter != null) m_OnPointerEnter(eventData, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnPointerExit(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
isPointerInChart = false;
|
||||||
|
if (m_OnPointerExit != null) m_OnPointerExit(eventData, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnBeginDrag(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (m_ScrollRect != null) m_ScrollRect.OnBeginDrag(eventData);
|
||||||
|
if (m_OnBeginDrag != null) m_OnBeginDrag(eventData, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnEndDrag(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (m_ScrollRect != null) m_ScrollRect.OnEndDrag(eventData);
|
||||||
|
if (m_OnEndDrag != null) m_OnEndDrag(eventData, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnDrag(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (m_ScrollRect != null) m_ScrollRect.OnDrag(eventData);
|
||||||
|
if (m_OnDrag != null) m_OnDrag(eventData, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnScroll(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (m_ScrollRect != null) m_ScrollRect.OnScroll(eventData);
|
||||||
|
if (m_OnScroll != null) m_OnScroll(eventData, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
111
Runtime/Internal/Utilities/InputHelper.cs
Normal file
111
Runtime/Internal/Utilities/InputHelper.cs
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
#if INPUT_SYSTEM_ENABLED
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
using UnityEngine.InputSystem.LowLevel;
|
||||||
|
|
||||||
|
namespace XCharts.Runtime
|
||||||
|
{
|
||||||
|
public class InputHelper
|
||||||
|
{
|
||||||
|
public static Vector2 mousePosition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var value = Vector2.zero;
|
||||||
|
if (null != Mouse.current)
|
||||||
|
{
|
||||||
|
value = Mouse.current.position.ReadValue();
|
||||||
|
}
|
||||||
|
else if (null != Touchscreen.current && Touchscreen.current.touches.Count > 0)
|
||||||
|
{
|
||||||
|
value = Touchscreen.current.touches[0].position.ReadValue();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static int touchCount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var value = 0;
|
||||||
|
if (null != Touchscreen.current)
|
||||||
|
{
|
||||||
|
value = Touchscreen.current.touches.Count;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Touch GetTouch(int v)
|
||||||
|
{
|
||||||
|
UnityEngine.TouchPhase PhaseConvert(TouchState state)
|
||||||
|
{
|
||||||
|
UnityEngine.TouchPhase temp = UnityEngine.TouchPhase.Began;
|
||||||
|
switch (state.phase)
|
||||||
|
{
|
||||||
|
case UnityEngine.InputSystem.TouchPhase.Began:
|
||||||
|
temp = UnityEngine.TouchPhase.Began;
|
||||||
|
break;
|
||||||
|
case UnityEngine.InputSystem.TouchPhase.Moved:
|
||||||
|
temp = UnityEngine.TouchPhase.Moved;
|
||||||
|
break;
|
||||||
|
case UnityEngine.InputSystem.TouchPhase.Canceled:
|
||||||
|
temp = UnityEngine.TouchPhase.Canceled;
|
||||||
|
break;
|
||||||
|
case UnityEngine.InputSystem.TouchPhase.Stationary:
|
||||||
|
temp = UnityEngine.TouchPhase.Stationary;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case UnityEngine.InputSystem.TouchPhase.Ended:
|
||||||
|
case UnityEngine.InputSystem.TouchPhase.None:
|
||||||
|
temp = UnityEngine.TouchPhase.Ended;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
var touch = Touchscreen.current.touches[v];
|
||||||
|
var value = touch.ReadValue();
|
||||||
|
//copy touchcontrol's touchstate data into touch
|
||||||
|
return new Touch
|
||||||
|
{
|
||||||
|
deltaPosition = value.delta,
|
||||||
|
fingerId = value.touchId,
|
||||||
|
position = value.position,
|
||||||
|
phase = PhaseConvert(value),
|
||||||
|
pressure = value.pressure,
|
||||||
|
radius = value.radius.magnitude,
|
||||||
|
radiusVariance = value.radius.sqrMagnitude,
|
||||||
|
type = value.isPrimaryTouch ? TouchType.Direct : TouchType.Indirect,
|
||||||
|
tapCount = value.tapCount,
|
||||||
|
deltaTime = Time.realtimeSinceStartup - (float)value.startTime,
|
||||||
|
rawPosition = value.startPosition,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool GetKeyDown(KeyCode keyCode)
|
||||||
|
{
|
||||||
|
var value = false;
|
||||||
|
if (null != Keyboard.current)
|
||||||
|
{
|
||||||
|
var key = Keyboard.current.spaceKey;
|
||||||
|
switch (keyCode)
|
||||||
|
{
|
||||||
|
case KeyCode.Space:
|
||||||
|
key = Keyboard.current.spaceKey;
|
||||||
|
break;
|
||||||
|
case KeyCode.L:
|
||||||
|
key = Keyboard.current.lKey;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Debug.LogError($"{nameof(InputHelper)}: not support {keyCode} yet , please add it yourself if needed");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = key.wasPressedThisFrame;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
11
Runtime/Internal/Utilities/InputHelper.cs.meta
Normal file
11
Runtime/Internal/Utilities/InputHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5069defa9fe8c7a43843e1189e2d606c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -2,8 +2,9 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
using System.Linq;
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using UnityEditor;
|
using ADB = UnityEditor.AssetDatabase;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace XCharts.Runtime
|
namespace XCharts.Runtime
|
||||||
@@ -127,6 +128,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
|
|
||||||
public static string GetPackageFullPath()
|
public static string GetPackageFullPath()
|
||||||
{
|
{
|
||||||
string packagePath = Path.GetFullPath("Packages/com.monitor1394.xcharts");
|
string packagePath = Path.GetFullPath("Packages/com.monitor1394.xcharts");
|
||||||
@@ -134,38 +136,13 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
return packagePath;
|
return packagePath;
|
||||||
}
|
}
|
||||||
packagePath = Path.GetFullPath("Assets/..");
|
packagePath = ADB.FindAssets("t:Script")
|
||||||
if (Directory.Exists(packagePath))
|
.Where(v => Path.GetFileNameWithoutExtension(ADB.GUIDToAssetPath(v)) == "XChartsMgr")
|
||||||
{
|
.Select(id => ADB.GUIDToAssetPath(id))
|
||||||
if (File.Exists(packagePath + "/Assets/Packages/XCharts/package.json"))
|
.FirstOrDefault();
|
||||||
{
|
packagePath = Path.GetDirectoryName(packagePath);
|
||||||
return packagePath + "/Assets/Packages/XCharts";
|
packagePath = packagePath.Substring(0, packagePath.LastIndexOf("Runtime"));
|
||||||
}
|
return packagePath;
|
||||||
|
|
||||||
if (File.Exists(packagePath + "/Assets/XCharts/package.json"))
|
|
||||||
{
|
|
||||||
return packagePath + "/Assets/XCharts";
|
|
||||||
}
|
|
||||||
|
|
||||||
string[] matchingPaths = Directory.GetDirectories(packagePath, "XCharts", SearchOption.AllDirectories);
|
|
||||||
string path = ValidateLocation(matchingPaths, packagePath);
|
|
||||||
if (path != null) return Path.Combine(packagePath, path);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string ValidateLocation(string[] paths, string projectPath)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < paths.Length; i++)
|
|
||||||
{
|
|
||||||
if (File.Exists(paths[i] + "/package.json"))
|
|
||||||
{
|
|
||||||
string folderPath = paths[i].Replace(projectPath, "");
|
|
||||||
folderPath = folderPath.TrimStart('\\', '/');
|
|
||||||
return folderPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[UnityEditor.Callbacks.DidReloadScripts]
|
[UnityEditor.Callbacks.DidReloadScripts]
|
||||||
@@ -185,133 +162,6 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EnableTextMeshPro()
|
|
||||||
{
|
|
||||||
DefineSymbolsUtil.AddGlobalDefine("dUI_TextMeshPro");
|
|
||||||
RemoveAllChartObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DisableTextMeshPro()
|
|
||||||
{
|
|
||||||
DefineSymbolsUtil.RemoveGlobalDefine("dUI_TextMeshPro");
|
|
||||||
RemoveAllChartObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsExistTMPAssembly()
|
|
||||||
{
|
|
||||||
|
|
||||||
#if UNITY_2018_1_OR_NEWER
|
|
||||||
foreach (var assembly in UnityEditor.Compilation.CompilationPipeline.GetAssemblies(UnityEditor.Compilation.AssembliesType.Player))
|
|
||||||
{
|
|
||||||
if (assembly.name.Equals("Unity.TextMeshPro")) return true;
|
|
||||||
}
|
|
||||||
#elif UNITY_2017_3_OR_NEWER
|
|
||||||
foreach (var assembly in UnityEditor.Compilation.CompilationPipeline.GetAssemblies())
|
|
||||||
{
|
|
||||||
if (assembly.name.Equals("Unity.TextMeshPro")) return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool ModifyTMPRefence(bool removeTMP = false)
|
|
||||||
{
|
|
||||||
var packagePath = GetPackageFullPath();
|
|
||||||
if (!ModifyTMPRefence(packagePath + "/Runtime/XCharts.Runtime.asmdef", removeTMP)) return false;
|
|
||||||
if (!ModifyTMPRefence(packagePath + "/Editor/XCharts.Editor.asmdef", removeTMP)) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool ModifyTMPRefence(string asmdefPath, bool removeTMP = false)
|
|
||||||
{
|
|
||||||
if (!File.Exists(asmdefPath))
|
|
||||||
{
|
|
||||||
Debug.LogError("AddTMPRefence ERROR: can't find: " + asmdefPath);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var dest = new List<string>();
|
|
||||||
var refs = new List<string>();
|
|
||||||
var lines = File.ReadAllLines(asmdefPath);
|
|
||||||
var referencesStart = false;
|
|
||||||
var addedTMP = false;
|
|
||||||
var removedTMP = false;
|
|
||||||
var tmpName = "\"Unity.TextMeshPro\"";
|
|
||||||
var refCount = 0;
|
|
||||||
foreach (var line in lines)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(line)) continue;
|
|
||||||
if (line.Contains("\"references\": ["))
|
|
||||||
{
|
|
||||||
dest.Add(line);
|
|
||||||
referencesStart = true;
|
|
||||||
}
|
|
||||||
else if (referencesStart)
|
|
||||||
{
|
|
||||||
if (line.Contains("],"))
|
|
||||||
{
|
|
||||||
referencesStart = false;
|
|
||||||
if (refCount > 0)
|
|
||||||
{
|
|
||||||
var old = dest[dest.Count - 1];
|
|
||||||
if (old.EndsWith(","))
|
|
||||||
dest[dest.Count - 1] = old.Substring(0, old.Length - 1);
|
|
||||||
}
|
|
||||||
if (!removeTMP && !refs.Contains(tmpName))
|
|
||||||
{
|
|
||||||
if (refs.Count > 0)
|
|
||||||
dest[dest.Count - 1] = dest[dest.Count - 1] + ",";
|
|
||||||
dest.Add(" " + tmpName);
|
|
||||||
dest.Add(line);
|
|
||||||
addedTMP = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dest.Add(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (removeTMP)
|
|
||||||
{
|
|
||||||
if (!line.Contains(tmpName))
|
|
||||||
{
|
|
||||||
dest.Add(line);
|
|
||||||
refCount++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
removedTMP = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dest.Add(line);
|
|
||||||
refs.Add(line.Trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dest.Add(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (addedTMP || removedTMP)
|
|
||||||
{
|
|
||||||
File.WriteAllText(asmdefPath, string.Join("\n", dest.ToArray()));
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
AssetDatabase.Refresh();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (System.Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogError("AddTMPRefence ERROR:" + e.Message);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "XCharts.Runtime",
|
"name": "XCharts.Runtime",
|
||||||
"references": [
|
"references": [],
|
||||||
],
|
|
||||||
"optionalUnityReferences": [],
|
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
"allowUnsafeCode": false,
|
"allowUnsafeCode": false,
|
||||||
"overrideReferences": false,
|
"overrideReferences": false,
|
||||||
"precompiledReferences": [],
|
"precompiledReferences": [],
|
||||||
"autoReferenced": true,
|
"autoReferenced": true,
|
||||||
"defineConstraints": []
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user