mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 18:30:14 +00:00
优化MultiComponentMode开启后的编辑体验和组件刷新 #128
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
## Latest
|
## Latest
|
||||||
|
|
||||||
|
* (2021.03.13) Optimize the editing experience and component refresh after `MulticomponentMode` is enabled #128
|
||||||
* (2021.03.10) Added `CandlestickChart` #124
|
* (2021.03.10) Added `CandlestickChart` #124
|
||||||
* (2021.03.06) Added `PieChart`'s `minAngle` parameter to support setting minimum sector angle #117
|
* (2021.03.06) Added `PieChart`'s `minAngle` parameter to support setting minimum sector angle #117
|
||||||
* (2021.03.05) Added support for `Legend` for several built-in ICONS #90
|
* (2021.03.05) Added support for `Legend` for several built-in ICONS #90
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
## Latest
|
## Latest
|
||||||
|
|
||||||
|
* (2021.03.13) 优化`MultiComponentMode`开启后的编辑体验和组件刷新 #128
|
||||||
* (2021.03.10) 增加`CandlestickChart`K线图 #124
|
* (2021.03.10) 增加`CandlestickChart`K线图 #124
|
||||||
* (2021.03.06) 增加`PieChart`的`minAngle`参数支持设置最小扇区角度 #117
|
* (2021.03.06) 增加`PieChart`的`minAngle`参数支持设置最小扇区角度 #117
|
||||||
* (2021.03.05) 增加`Legend`几种内置图标的支持 #90
|
* (2021.03.05) 增加`Legend`几种内置图标的支持 #90
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ namespace XCharts
|
|||||||
#if UNITY_2019_3_OR_NEWER
|
#if UNITY_2019_3_OR_NEWER
|
||||||
private const float k_IconWidth = 14;
|
private const float k_IconWidth = 14;
|
||||||
private const float k_IconGap = 0f;
|
private const float k_IconGap = 0f;
|
||||||
private const float k_IconXOffset = 7f;
|
private const float k_IconXOffset = 10f;
|
||||||
private const float k_IconYOffset = -1f;
|
private const float k_IconYOffset = -1.5f;
|
||||||
#else
|
#else
|
||||||
private const float k_IconWidth = 14;
|
private const float k_IconWidth = 14;
|
||||||
private const float k_IconGap = 0f;
|
private const float k_IconGap = 0f;
|
||||||
@@ -200,20 +200,47 @@ namespace XCharts
|
|||||||
if (m_Flodouts[prop.displayName])
|
if (m_Flodouts[prop.displayName])
|
||||||
{
|
{
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
prop.arraySize = EditorGUILayout.IntField("Size", prop.arraySize);
|
//prop.arraySize = EditorGUILayout.IntField("Size", prop.arraySize);
|
||||||
|
var currRect = EditorGUILayout.GetControlRect(GUILayout.Height(0));
|
||||||
|
currRect.y -= EditorGUIUtility.singleLineHeight;
|
||||||
|
var rect1 = new Rect(currRect.width + k_IconXOffset,
|
||||||
|
currRect.y + k_IconYOffset,
|
||||||
|
k_IconWidth, EditorGUIUtility.singleLineHeight);
|
||||||
|
if (GUI.Button(rect1, ChartEditorHelper.Styles.iconAdd, ChartEditorHelper.Styles.invisibleButton))
|
||||||
|
{
|
||||||
|
prop.InsertArrayElementAtIndex(prop.arraySize > 0 ? prop.arraySize - 1 : 0);
|
||||||
|
}
|
||||||
for (int i = 0; i < prop.arraySize; i++)
|
for (int i = 0; i < prop.arraySize; i++)
|
||||||
{
|
{
|
||||||
EditorGUILayout.PropertyField(prop.GetArrayElementAtIndex(i), true);
|
EditorGUILayout.PropertyField(prop.GetArrayElementAtIndex(i), true);
|
||||||
var currRect = EditorGUILayout.GetControlRect(GUILayout.Height(0));
|
currRect = EditorGUILayout.GetControlRect(GUILayout.Height(0));
|
||||||
currRect.y -= EditorGUI.GetPropertyHeight(prop.GetArrayElementAtIndex(i));
|
currRect.y -= EditorGUI.GetPropertyHeight(prop.GetArrayElementAtIndex(i));
|
||||||
var rect1 = new Rect(currRect.width + k_IconXOffset,
|
rect1 = new Rect(currRect.width + k_IconXOffset,
|
||||||
currRect.y + k_IconYOffset,
|
currRect.y + k_IconYOffset,
|
||||||
k_IconWidth, EditorGUIUtility.singleLineHeight);
|
k_IconWidth, EditorGUIUtility.singleLineHeight);
|
||||||
var oldColor = GUI.contentColor;
|
var oldColor = GUI.contentColor;
|
||||||
GUI.contentColor = Color.black;
|
GUI.contentColor = Color.black;
|
||||||
if (GUI.Button(rect1, ChartEditorHelper.Styles.iconRemove, ChartEditorHelper.Styles.invisibleButton))
|
if (GUI.Button(rect1, ChartEditorHelper.Styles.iconRemove, ChartEditorHelper.Styles.invisibleButton))
|
||||||
{
|
{
|
||||||
if (i < prop.arraySize && i >= 0) prop.DeleteArrayElementAtIndex(i);
|
if (prop.arraySize == 1)
|
||||||
|
{
|
||||||
|
if (EditorUtility.DisplayDialog("Delete component", "Confirm to delete last component?", "Sure", "Cancel"))
|
||||||
|
{
|
||||||
|
var chart = prop.GetArrayElementAtIndex(0).serializedObject.targetObject as BaseChart;
|
||||||
|
prop.DeleteArrayElementAtIndex(i);
|
||||||
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
chart.RemoveChartObject();
|
||||||
|
chart.RefreshAllComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (i < prop.arraySize && i >= 0)
|
||||||
|
{
|
||||||
|
var chart = prop.GetArrayElementAtIndex(0).serializedObject.targetObject as BaseChart;
|
||||||
|
prop.DeleteArrayElementAtIndex(i);
|
||||||
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
chart.RemoveChartObject();
|
||||||
|
chart.RefreshAllComponent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var rect2 = new Rect(currRect.width + k_IconXOffset - k_IconWidth - k_IconGap,
|
var rect2 = new Rect(currRect.width + k_IconXOffset - k_IconWidth - k_IconGap,
|
||||||
currRect.y + k_IconYOffset,
|
currRect.y + k_IconYOffset,
|
||||||
|
|||||||
@@ -124,6 +124,19 @@ namespace XCharts
|
|||||||
GameObject.DestroyImmediate(go.gameObject);
|
GameObject.DestroyImmediate(go.gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void DestoryGameObjectByMatch(Transform parent, string match)
|
||||||
|
{
|
||||||
|
if (parent == null) return;
|
||||||
|
var childCount = parent.childCount;
|
||||||
|
for (int i = childCount - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
var go = parent.GetChild(i);
|
||||||
|
if (go != null && go.name.StartsWith(match))
|
||||||
|
{
|
||||||
|
GameObject.DestroyImmediate(go.gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void DestoryGameObject(GameObject go)
|
public static void DestoryGameObject(GameObject go)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user