海拔图和小地图
This commit is contained in:
1 parent
42fa59d103
commit
8ad36c965d
521 files changed
+1985033
-439
No files matched your search
@@ -0,0 +1,155 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XChartsDemo
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(ChartModule), true)]
|
||||
internal class ChartModuleDrawer : PropertyDrawer
|
||||
{
|
||||
public class Styles
|
||||
{
|
||||
public static readonly GUIContent iconAdd = new GUIContent("+", "Add");
|
||||
public static readonly GUIContent iconRemove = new GUIContent("-", "Remove");
|
||||
public static readonly GUIContent iconUp = new GUIContent("↑", "Up");
|
||||
public static readonly GUIContent iconDown = new GUIContent("↓", "Down");
|
||||
public static readonly GUIStyle invisibleButton = "InvisibleButton";
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
var lastX = drawRect.x;
|
||||
var lastWid = drawRect.width;
|
||||
SerializedProperty m_Column = prop.FindPropertyRelative("m_Column");
|
||||
SerializedProperty m_Name = prop.FindPropertyRelative("m_Name");
|
||||
SerializedProperty m_SubName = prop.FindPropertyRelative("m_SubName");
|
||||
SerializedProperty m_Title = prop.FindPropertyRelative("m_Title");
|
||||
SerializedProperty m_Selected = prop.FindPropertyRelative("m_Selected");
|
||||
SerializedProperty m_Panel = prop.FindPropertyRelative("m_Panel");
|
||||
var fieldWid = EditorGUIUtility.currentViewWidth - 30 - 5 - 40 - 80 - 50 - 100 - 6 * 2 - 70;
|
||||
drawRect.width = 15;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var oldFlag = m_Selected.boolValue;
|
||||
EditorGUI.PropertyField(drawRect, m_Selected, GUIContent.none);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
var demo = prop.serializedObject.targetObject as Demo;
|
||||
var index = GetIndex(prop);
|
||||
var selectedIndex = demo.GetSelectedModule();
|
||||
if (selectedIndex != index)
|
||||
{
|
||||
for (int i = 0; i < demo.chartModules.Count; i++)
|
||||
{
|
||||
demo.chartModules[i].select = i == index && m_Selected.boolValue;
|
||||
}
|
||||
demo.InitModuleButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Selected.boolValue = oldFlag;
|
||||
}
|
||||
}
|
||||
drawRect.x += 17;
|
||||
drawRect.width = 80;
|
||||
EditorGUI.PropertyField(drawRect, m_Name, GUIContent.none);
|
||||
drawRect.x += 82;
|
||||
drawRect.width = 50;
|
||||
EditorGUI.PropertyField(drawRect, m_SubName, GUIContent.none);
|
||||
drawRect.x += 52;
|
||||
drawRect.width = fieldWid;
|
||||
EditorGUI.PropertyField(drawRect, m_Title, GUIContent.none);
|
||||
drawRect.x += fieldWid + 2;
|
||||
drawRect.width = 100;
|
||||
EditorGUI.PropertyField(drawRect, m_Panel, GUIContent.none);
|
||||
drawRect.x += 102;
|
||||
drawRect.width = 40;
|
||||
EditorGUI.PropertyField(drawRect, m_Column, GUIContent.none);
|
||||
|
||||
var btnWidth = 12;
|
||||
drawRect.x += 42;
|
||||
drawRect.width = btnWidth;
|
||||
if (GUI.Button(drawRect, Styles.iconUp, Styles.invisibleButton))
|
||||
{
|
||||
var demo = prop.serializedObject.targetObject as Demo;
|
||||
var index = GetIndex(prop);
|
||||
if (index >= 0)
|
||||
{
|
||||
Swap(demo.chartModules, index, index - 1);
|
||||
demo.InitModuleButton();
|
||||
}
|
||||
}
|
||||
drawRect.x += btnWidth + 1;
|
||||
if (GUI.Button(drawRect, Styles.iconDown, Styles.invisibleButton))
|
||||
{
|
||||
var demo = prop.serializedObject.targetObject as Demo;
|
||||
var index = GetIndex(prop);
|
||||
if (index >= 0)
|
||||
{
|
||||
Swap(demo.chartModules, index, index + 1);
|
||||
demo.InitModuleButton();
|
||||
}
|
||||
}
|
||||
drawRect.x += btnWidth + 1;
|
||||
if (GUI.Button(drawRect, Styles.iconAdd, Styles.invisibleButton))
|
||||
{
|
||||
var demo = prop.serializedObject.targetObject as Demo;
|
||||
var index = GetIndex(prop);
|
||||
if (index >= 0)
|
||||
{
|
||||
demo.chartModules.Insert(index + 1, new ChartModule());
|
||||
demo.InitModuleButton();
|
||||
}
|
||||
}
|
||||
drawRect.x += 16;
|
||||
if (GUI.Button(drawRect, Styles.iconRemove, Styles.invisibleButton))
|
||||
{
|
||||
var demo = prop.serializedObject.targetObject as Demo;
|
||||
var index = GetIndex(prop);
|
||||
if (index >= 0)
|
||||
{
|
||||
demo.chartModules.RemoveAt(index);
|
||||
demo.InitModuleButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
|
||||
private int GetIndex(SerializedProperty prop)
|
||||
{
|
||||
int index = -1;
|
||||
var sindex = prop.propertyPath.LastIndexOf('[');
|
||||
var eindex = prop.propertyPath.LastIndexOf(']');
|
||||
if (sindex >= 0 && eindex >= 0)
|
||||
{
|
||||
var str = prop.propertyPath.Substring(sindex + 1, eindex - sindex - 1);
|
||||
int.TryParse(str, out index);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
private static bool Swap<T>(List<T> list, int index1, int index2)
|
||||
{
|
||||
if (index1 < 0 || index1 >= list.Count) return false;
|
||||
if (index2 < 0 || index2 >= list.Count) return false;
|
||||
var temp = list[index1];
|
||||
list[index1] = list[index2];
|
||||
list[index2] = temp;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fbbaed3e670f478c844c1bdfc73d433
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,76 @@
|
||||
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace XChartsDemo
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor class used to edit UI BaseChart.
|
||||
/// </summary>
|
||||
|
||||
[CustomEditor(typeof(Demo), false)]
|
||||
internal class DemoEditor : Editor
|
||||
{
|
||||
protected Demo m_Target;
|
||||
protected SerializedProperty m_Script;
|
||||
protected SerializedProperty m_LeftWidth;
|
||||
protected SerializedProperty m_LeftButtonHeight;
|
||||
protected SerializedProperty m_ChartSpacing;
|
||||
protected SerializedProperty m_ChartSizeRatio;
|
||||
protected SerializedProperty m_ButtonNormalColor;
|
||||
protected SerializedProperty m_ButtonSelectedColor;
|
||||
protected SerializedProperty m_ButtonHighlightColor;
|
||||
protected SerializedProperty m_ChartModule;
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
m_Target = (Demo)target;
|
||||
m_Script = serializedObject.FindProperty("m_Script");
|
||||
m_LeftWidth = serializedObject.FindProperty("m_LeftWidth");
|
||||
m_ChartSpacing = serializedObject.FindProperty("m_ChartSpacing");
|
||||
m_ChartSizeRatio = serializedObject.FindProperty("m_ChartSizeRatio");
|
||||
m_LeftButtonHeight = serializedObject.FindProperty("m_LeftButtonHeight");
|
||||
m_ButtonNormalColor = serializedObject.FindProperty("m_ButtonNormalColor");
|
||||
m_ButtonSelectedColor = serializedObject.FindProperty("m_ButtonSelectedColor");
|
||||
m_ButtonHighlightColor = serializedObject.FindProperty("m_ButtonHighlightColor");
|
||||
m_ChartModule = serializedObject.FindProperty("m_ChartModule");
|
||||
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (m_Target == null && target == null)
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
return;
|
||||
}
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(m_LeftWidth);
|
||||
EditorGUILayout.PropertyField(m_LeftButtonHeight);
|
||||
EditorGUILayout.PropertyField(m_ChartSpacing);
|
||||
EditorGUILayout.PropertyField(m_ChartSizeRatio);
|
||||
EditorGUILayout.PropertyField(m_ButtonNormalColor);
|
||||
EditorGUILayout.PropertyField(m_ButtonSelectedColor);
|
||||
EditorGUILayout.PropertyField(m_ButtonHighlightColor);
|
||||
|
||||
var size = m_ChartModule.arraySize;
|
||||
size = EditorGUILayout.IntField("Chart Module Size", size);
|
||||
if (size != m_ChartModule.arraySize)
|
||||
{
|
||||
while (size > m_ChartModule.arraySize) m_ChartModule.arraySize++;
|
||||
while (size < m_ChartModule.arraySize) m_ChartModule.arraySize--;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_ChartModule.GetArrayElementAtIndex(i));
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90c1787bea03849c8b6d19be625b7e17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user