작업 조건 분석 기능 개발
This commit is contained in:
29
Assets/Chart And Graph/Script/Text/AlignedItemLabels.cs
Normal file
29
Assets/Chart And Graph/Script/Text/AlignedItemLabels.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
public abstract class AlignedItemLabels : ItemLabelsBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Select the alignment of the label relative to the item
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
[Tooltip("Select the alignment of the label relative to the item")]
|
||||
private ChartLabelAlignment alignment;
|
||||
|
||||
/// <summary>
|
||||
/// Select the alignment of the label relative to the item
|
||||
/// </summary>
|
||||
public ChartLabelAlignment Alignment
|
||||
{
|
||||
get { return alignment; }
|
||||
set { alignment = value; RaiseOnUpdate(); }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Text/AlignedItemLabels.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Text/AlignedItemLabels.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9e0fcd89d080ad45bcfbe3299080c39
|
||||
timeCreated: 1478847129
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/Chart And Graph/Script/Text/BillboardText.cs
Normal file
48
Assets/Chart And Graph/Script/Text/BillboardText.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// repsents a chart item text that is billboarded in a unity scene
|
||||
/// </summary>
|
||||
public class BillboardText : MonoBehaviour
|
||||
{
|
||||
private RectTransform mRect;
|
||||
public GameObject UIText { get; set; }
|
||||
public TextDirection Direction;
|
||||
public RectTransform RectTransformOverride;
|
||||
public object UserData { get; set; }
|
||||
[NonSerialized]
|
||||
public float Scale = 1f;
|
||||
public bool parentSet = false;
|
||||
public RectTransform parent = null;
|
||||
public bool Recycled = false;
|
||||
public bool YMirror = false;
|
||||
CanvasRenderer[] mRenderers;
|
||||
public void SetVisible(bool visible)
|
||||
{
|
||||
bool cull = !visible;
|
||||
RectTransform t = Rect;
|
||||
if (t == null)
|
||||
return;
|
||||
if (mRenderers == null)
|
||||
mRenderers = t.GetComponentsInChildren<CanvasRenderer>();
|
||||
for(int i=0; i< mRenderers.Length; i++)
|
||||
mRenderers[i].cull = cull;
|
||||
}
|
||||
public RectTransform Rect
|
||||
{
|
||||
get
|
||||
{
|
||||
if (UIText == null)
|
||||
return null;
|
||||
if (RectTransformOverride != null)
|
||||
return RectTransformOverride;
|
||||
if (mRect == null)
|
||||
mRect = UIText.GetComponent<RectTransform>();
|
||||
return mRect;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Text/BillboardText.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Text/BillboardText.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6664fc8f2f18cc147bbdc9790ab8e9ac
|
||||
timeCreated: 1474910934
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/Chart And Graph/Script/Text/CategoryLabels.cs
Normal file
50
Assets/Chart And Graph/Script/Text/CategoryLabels.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class CategoryLabels : AlignedItemLabels
|
||||
{
|
||||
public enum ChartCategoryLabelOptions
|
||||
{
|
||||
All,
|
||||
FirstOnly
|
||||
}
|
||||
/// <summary>
|
||||
/// Determines which labels are visible
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
[Tooltip("Determines which labels are visible")]
|
||||
private ChartCategoryLabelOptions visibleLabels;
|
||||
/// <summary>
|
||||
/// Determines which labels are visible
|
||||
/// </summary>
|
||||
public ChartCategoryLabelOptions VisibleLabels
|
||||
{
|
||||
get { return visibleLabels; }
|
||||
set { visibleLabels = value; RaiseOnChanged(); }
|
||||
}
|
||||
|
||||
protected override Action<IInternalUse, bool> Assign
|
||||
{
|
||||
get
|
||||
{
|
||||
return (x, clear) =>
|
||||
{
|
||||
if (clear)
|
||||
{
|
||||
if (x.CategoryLabels == this)
|
||||
x.CategoryLabels = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x.CategoryLabels != this)
|
||||
x.CategoryLabels = this;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Text/CategoryLabels.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Text/CategoryLabels.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 683c1c28d013cce4c9128c952dbdca81
|
||||
timeCreated: 1478008114
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
13
Assets/Chart And Graph/Script/Text/ChartLabelAlignment.cs
Normal file
13
Assets/Chart And Graph/Script/Text/ChartLabelAlignment.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
public enum ChartLabelAlignment
|
||||
{
|
||||
Top,
|
||||
Base,
|
||||
Center
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca3eae5850818a2448ea60b621574b44
|
||||
timeCreated: 1475923681
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Chart And Graph/Script/Text/ChartText.cs
Normal file
16
Assets/Chart And Graph/Script/Text/ChartText.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class ChartText : MonoBehaviour {
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Text/ChartText.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Text/ChartText.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 724f9b49f5da3fb4cb7bb61e956602e7
|
||||
timeCreated: 1535733592
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/Chart And Graph/Script/Text/GroupLabelAlignment.cs
Normal file
40
Assets/Chart And Graph/Script/Text/GroupLabelAlignment.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
public enum GroupLabelAlignment
|
||||
{
|
||||
/// <summary>
|
||||
/// add the label at the center of each group
|
||||
/// </summary>
|
||||
Center,
|
||||
/// <summary>
|
||||
/// add the label at the end of each group
|
||||
/// </summary>
|
||||
EndOfGroup,
|
||||
/// <summary>
|
||||
/// add the label at the begining of each group
|
||||
/// </summary>
|
||||
BeginingOfGroup,
|
||||
/// <summary>
|
||||
/// alternate between both sides of the group
|
||||
/// </summary>
|
||||
AlternateSides,
|
||||
/// <summary>
|
||||
/// add a label at the top of each bar
|
||||
/// </summary>
|
||||
BarTop,
|
||||
/// <summary>
|
||||
/// add a label at the bottom of each bar
|
||||
/// </summary>
|
||||
BarBottom,
|
||||
/// <summary>
|
||||
/// add a label at the first bar of each group
|
||||
/// </summary>
|
||||
FirstBar
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 749775324726a1c449543359b020d43a
|
||||
timeCreated: 1478358876
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
47
Assets/Chart And Graph/Script/Text/GroupLabels.cs
Normal file
47
Assets/Chart And Graph/Script/Text/GroupLabels.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class GroupLabels : ItemLabelsBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Detemines the alignment of the group labels
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
[Tooltip("Detemines the alignment of the group labels")]
|
||||
private GroupLabelAlignment alignment;
|
||||
|
||||
/// <summary>
|
||||
/// Detemines the alignment of the group labels
|
||||
/// </summary>
|
||||
public GroupLabelAlignment Alignment
|
||||
{
|
||||
get { return alignment; }
|
||||
set { alignment = value; RaiseOnUpdate(); }
|
||||
}
|
||||
|
||||
protected override Action<IInternalUse, bool> Assign
|
||||
{
|
||||
get
|
||||
{
|
||||
return (x, clear) =>
|
||||
{
|
||||
if (clear)
|
||||
{
|
||||
if (x.GroupLabels == this)
|
||||
x.GroupLabels = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x.GroupLabels != this)
|
||||
x.GroupLabels = this;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Text/GroupLabels.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Text/GroupLabels.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a5935733d0eb5b48ba1db228c83f0f0
|
||||
timeCreated: 1478008114
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
47
Assets/Chart And Graph/Script/Text/ItemLabels.cs
Normal file
47
Assets/Chart And Graph/Script/Text/ItemLabels.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
public class ItemLabels : AlignedItemLabels
|
||||
{
|
||||
/// <summary>
|
||||
/// the number of fraction digits in the text labels
|
||||
/// </summary>
|
||||
[Range(0, 7)]
|
||||
[SerializeField]
|
||||
private int fractionDigits;
|
||||
|
||||
/// <summary>
|
||||
/// the number of fraction digits in the text labels
|
||||
/// </summary>
|
||||
public int FractionDigits
|
||||
{
|
||||
get { return fractionDigits; }
|
||||
set { fractionDigits = value; RaiseOnUpdate(); }
|
||||
}
|
||||
protected override Action<IInternalUse, bool> Assign
|
||||
{
|
||||
get
|
||||
{
|
||||
return (x, clear) =>
|
||||
{
|
||||
if (clear)
|
||||
{
|
||||
if (x.ItemLabels == this)
|
||||
x.ItemLabels = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x.ItemLabels != this)
|
||||
x.ItemLabels = this;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Text/ItemLabels.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Text/ItemLabels.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5eb3e26fd06b41d4baa022120f5cd617
|
||||
timeCreated: 1478008114
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
140
Assets/Chart And Graph/Script/Text/ItemLabelsBase.cs
Normal file
140
Assets/Chart And Graph/Script/Text/ItemLabelsBase.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[Serializable]
|
||||
public abstract class ItemLabelsBase : ChartSettingItemBase,ISerializationCallbackReceiver
|
||||
{
|
||||
/// <summary>
|
||||
/// This prefab will be used to create all the text associated with the chart. If the prefab is null no labels will be shown
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
[Tooltip("This prefab will be used to create all the text associated with the chart. If the prefab is null no labels will be shown")]
|
||||
private MonoBehaviour textPrefab;
|
||||
|
||||
/// <summary>
|
||||
/// This prefab will be used to create all the text associated with the chart. If the prefab is null no labels will be shown
|
||||
/// </summary>
|
||||
public MonoBehaviour TextPrefab
|
||||
{
|
||||
get { return textPrefab; }
|
||||
set { textPrefab = value; RaiseOnChanged(); }
|
||||
}
|
||||
|
||||
|
||||
public ItemLabelsBase()
|
||||
{
|
||||
AddChildObjects();
|
||||
}
|
||||
|
||||
void AddChildObjects()
|
||||
{
|
||||
if (textFormat != null)
|
||||
AddInnerItem(textFormat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// determine the formatting of the label data. when the values are available , you can use the predefined macros : "\n" for newline , '<?category>' for the current category and '<?group>' for the current group
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
[Tooltip(@" determine the formatting of the label data. when the values are available , you can use the predefined macros : '\n' for newline , '<?category>' for the current category and '<?group>' for the current group")]
|
||||
private TextFormatting textFormat = new TextFormatting();
|
||||
|
||||
/// <summary>
|
||||
/// determine the formatting of the label data. when the values are available , you can use the predefined macros : "\n" for newline , '<?category>' for the current category and '<?group>' for the current group
|
||||
/// </summary>
|
||||
public TextFormatting TextFormat
|
||||
{
|
||||
get { return textFormat; }
|
||||
set
|
||||
{
|
||||
textFormat = value;
|
||||
RaiseOnUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The size of the text.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
[Tooltip("the font size for the labels")]
|
||||
private int fontSize = 14;
|
||||
|
||||
/// <summary>
|
||||
/// The size of the text.
|
||||
/// </summary>
|
||||
public int FontSize
|
||||
{
|
||||
get { return fontSize; }
|
||||
set { fontSize = value; RaiseOnUpdate(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// adjusts the sharpness of the font
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
[Range(1f,3f)]
|
||||
[Tooltip("adjusts the sharpness of the font")]
|
||||
private float fontSharpness = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// adjusts the sharpness of the font
|
||||
/// </summary>
|
||||
public float FontSharpness
|
||||
{
|
||||
get { return fontSharpness; }
|
||||
set { fontSharpness = value; RaiseOnUpdate(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the seperation of each label from it's origin
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
[Tooltip("the seperation of each label from it's origin")]
|
||||
private float seperation = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// the seperation of each label from it's origin
|
||||
/// </summary>
|
||||
public float Seperation
|
||||
{
|
||||
get { return seperation; }
|
||||
set { seperation = value; RaiseOnUpdate(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// validates all properties
|
||||
/// </summary>
|
||||
public virtual void ValidateProperties()
|
||||
{
|
||||
fontSize = Mathf.Max(fontSize, 0);
|
||||
fontSharpness = Mathf.Clamp(fontSharpness, 1f, 3f);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// the location of the label relative to the item
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
[Tooltip("the location of the label relative to the item")]
|
||||
private ChartOrientedSize location = new ChartOrientedSize(0f,0f);
|
||||
|
||||
/// <summary>
|
||||
/// the location of the label relative to the item
|
||||
/// </summary>
|
||||
public ChartOrientedSize Location
|
||||
{
|
||||
get { return location; }
|
||||
set { location = value; RaiseOnUpdate(); }
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
AddChildObjects();
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Text/ItemLabelsBase.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Text/ItemLabelsBase.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 659526ff871773d4d95cfe8b8993ea70
|
||||
timeCreated: 1478358876
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
418
Assets/Chart And Graph/Script/Text/TextController.cs
Normal file
418
Assets/Chart And Graph/Script/Text/TextController.cs
Normal file
@@ -0,0 +1,418 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// posistions world space text on a special canvas used for billboarding.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(ChartItem))]
|
||||
[ExecuteInEditMode]
|
||||
public class TextController : MonoBehaviour
|
||||
{
|
||||
public Camera Camera = null;
|
||||
Canvas mCanvas;
|
||||
RectTransform mRect;
|
||||
List<BillboardText> mText = new List<BillboardText>();
|
||||
public float PlaneDistance = 4;
|
||||
Vector3[] mPlaneCorners = new Vector3[4];
|
||||
bool mInvalidated = false;
|
||||
private AnyChart mPrivateParent;
|
||||
float mPrevScale = -1f;
|
||||
bool OwnsCanvas = false;
|
||||
//private bool mUnderCanvas = false;
|
||||
internal List<BillboardText> Text { get { return mText; } }
|
||||
GameObject mAddCanvasUnder = null;
|
||||
float mInnerScale = 1.0f;
|
||||
|
||||
public float GlobalRotation
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
internal void SetInnerScale(float scale)
|
||||
{
|
||||
mInnerScale = scale;
|
||||
}
|
||||
|
||||
internal AnyChart mParent
|
||||
{
|
||||
get { return mPrivateParent; }
|
||||
set
|
||||
{
|
||||
mPrivateParent = value;
|
||||
if (mPrivateParent != null)
|
||||
{
|
||||
Camera = ((IInternalUse)mPrivateParent).InternalTextCamera;
|
||||
PlaneDistance = ((IInternalUse)mPrivateParent).InternalTextIdleDistance;
|
||||
if (OwnsCanvas)
|
||||
SafeCanvas.planeDistance = PlaneDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
EnsureCanvas();
|
||||
Canvas.willRenderCanvases += Canvas_willRenderCanvases;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Canvas.willRenderCanvases -= Canvas_willRenderCanvases;
|
||||
}
|
||||
|
||||
private void Canvas_willRenderCanvases()
|
||||
{
|
||||
|
||||
if (this == null)
|
||||
{
|
||||
Canvas.willRenderCanvases -= Canvas_willRenderCanvases;
|
||||
return;
|
||||
}
|
||||
ApplyTextPosition();
|
||||
}
|
||||
|
||||
void EnsureCanvas()
|
||||
{
|
||||
|
||||
if (mCanvas == null)
|
||||
{
|
||||
mCanvas = GetComponentInParent<Canvas>();
|
||||
if (mCanvas == null)
|
||||
{
|
||||
OwnsCanvas = true;
|
||||
mAddCanvasUnder = new GameObject();
|
||||
ChartCommon.HideObject(mAddCanvasUnder, true);
|
||||
mAddCanvasUnder.AddComponent<ChartItemNoDelete>();
|
||||
mAddCanvasUnder.AddComponent<RectTransform>();
|
||||
mAddCanvasUnder.transform.SetParent(gameObject.transform, false);
|
||||
mAddCanvasUnder.transform.localPosition = Vector3.zero;
|
||||
mAddCanvasUnder.transform.localScale = new Vector3(1f, 1f, 1f);
|
||||
mAddCanvasUnder.transform.localRotation = Quaternion.identity;
|
||||
|
||||
mCanvas = mAddCanvasUnder.AddComponent<Canvas>();
|
||||
mAddCanvasUnder.AddComponent<CanvasScaler>();
|
||||
mAddCanvasUnder.AddComponent<GraphicRaycaster>();
|
||||
|
||||
if (mParent != null && (mParent.VRSpaceText || mParent.PaperEffectText))
|
||||
{
|
||||
mCanvas.renderMode = RenderMode.WorldSpace;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCanvas.renderMode = RenderMode.ScreenSpaceCamera;
|
||||
}
|
||||
mCanvas.planeDistance = PlaneDistance;
|
||||
Camera = EnsureCamera();
|
||||
mRect = mCanvas.GetComponent<RectTransform>();
|
||||
// mCanvas.pixelPerfect = true;
|
||||
CanvasScaler scaler = mCanvas.GetComponent<CanvasScaler>();
|
||||
scaler.uiScaleMode = CanvasScaler.ScaleMode.ConstantPixelSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
//mUnderCanvas = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Canvas SafeCanvas
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureCanvas();
|
||||
return mCanvas;
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestory()
|
||||
{
|
||||
DestroyAll();
|
||||
}
|
||||
|
||||
public void DestroyAll()
|
||||
{
|
||||
for (int i = 0; i < mText.Count; i++)
|
||||
{
|
||||
if (mText[i] != null && mText[i].Recycled == false)
|
||||
{
|
||||
if (mText[i].UIText != null)
|
||||
ChartCommon.SafeDestroy(mText[i].UIText.gameObject);
|
||||
if (mText[i].RectTransformOverride != null)
|
||||
ChartCommon.SafeDestroy(mText[i].RectTransformOverride.gameObject);
|
||||
mText[i].UIText = null;
|
||||
mText[i].RectTransformOverride = null;
|
||||
ChartCommon.SafeDestroy(mText[i].gameObject);
|
||||
}
|
||||
}
|
||||
mText.Clear();
|
||||
}
|
||||
|
||||
public void AddText(BillboardText billboard)
|
||||
{
|
||||
if (billboard == null)
|
||||
return;
|
||||
if (billboard.UIText == null)
|
||||
return;
|
||||
|
||||
mInvalidated = false;
|
||||
mText.Add(billboard);
|
||||
var rect = billboard.Rect;
|
||||
EnsureCanvas();
|
||||
float yScale = (billboard.YMirror == true) ? -1f : 1f;
|
||||
if (rect == null)
|
||||
{
|
||||
var meshObj = billboard.UIText;
|
||||
TextDirection dir = meshObj.GetComponent<TextDirection>();
|
||||
if (dir != null)
|
||||
dir.SetTextController(this);
|
||||
|
||||
billboard.parent = null;
|
||||
meshObj.transform.SetParent(transform, false);
|
||||
if (mParent != null)
|
||||
meshObj.layer = mParent.gameObject.layer;
|
||||
|
||||
// meshObj.transform.localRotation = Quaternion.identity;
|
||||
Vector3 v = billboard.transform.position;
|
||||
if (!float.IsNaN(v.x) && !float.IsNaN(v.y) && !float.IsNaN(v.z))
|
||||
meshObj.transform.position = v;
|
||||
// meshObj.transform.localScale = new Vector3(1f, 1f, 1f);
|
||||
|
||||
meshObj.transform.localScale = new Vector3(billboard.Scale * mInnerScale, yScale* billboard.Scale * mInnerScale, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextDirection dir = rect.GetComponent<TextDirection>();
|
||||
if (dir != null)
|
||||
dir.SetTextController(this);
|
||||
|
||||
GameObject obj = ChartCommon.CreateCanvasChartItem();
|
||||
RectTransform t = obj.GetComponent<RectTransform>();
|
||||
obj.AddComponent<Canvas>();
|
||||
var addUnder = mAddCanvasUnder;
|
||||
if (addUnder == null)
|
||||
addUnder = gameObject;
|
||||
|
||||
obj.transform.SetParent(addUnder.transform, false);
|
||||
obj.transform.localPosition = Vector3.zero;
|
||||
// obj.transform.localRotation = Quaternion.identity;
|
||||
obj.transform.localScale = new Vector3(1f,1f,1f);
|
||||
|
||||
billboard.parent = t;
|
||||
billboard.Rect.SetParent(t, false);
|
||||
if (mParent != null)
|
||||
{
|
||||
obj.layer = mParent.gameObject.layer;
|
||||
billboard.Rect.gameObject.layer = mParent.gameObject.layer;
|
||||
}
|
||||
// billboard.Rect.localRotation = Quaternion.identity;
|
||||
billboard.Rect.localPosition = Vector3.zero;
|
||||
billboard.Rect.localScale = new Vector3(1f, 1f, 1f);
|
||||
|
||||
// rect.anchoredPosition3D = new Vector3();
|
||||
if (dir == null)
|
||||
{
|
||||
rect.anchorMin = Vector2.zero;
|
||||
rect.anchorMax = Vector2.zero;
|
||||
}
|
||||
Vector3 v = billboard.transform.position;
|
||||
if (!float.IsNaN(v.x) && !float.IsNaN(v.y) && !float.IsNaN(v.z))
|
||||
billboard.parent.position = v;
|
||||
billboard.UIText.transform.localScale = new Vector3(billboard.Scale * mInnerScale, yScale* billboard.Scale * mInnerScale, 1f);
|
||||
billboard.UIText.transform.Rotate(new Vector3(0f, 0f, GlobalRotation));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Vector3 scale = new Vector3(1f/transform.lossyScale.x, 1f/transform.lossyScale.y, 1f/transform.lossyScale.z);//SafeCanvas.transform.localScale;
|
||||
//Vector3 scale = SafeCanvas.transform.localScale;
|
||||
|
||||
//if (mUnderCanvas)
|
||||
// billboard.UIText.transform.localScale = scale;
|
||||
//else
|
||||
|
||||
|
||||
|
||||
// ContentSizeFitter fitter = billboard.UIText.gameObject.GetComponent<ContentSizeFitter>();
|
||||
// if(fitter == null)
|
||||
// fitter = billboard.UIText.gameObject.AddComponent<ContentSizeFitter>();
|
||||
// fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
// fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Camera EnsureCamera()
|
||||
{
|
||||
if (Camera == null)
|
||||
return AssignCamera(Camera.main);
|
||||
else
|
||||
return AssignCamera(Camera);
|
||||
}
|
||||
|
||||
Camera AssignCamera(Camera camera)
|
||||
{
|
||||
Canvas canvas = SafeCanvas;
|
||||
if (canvas.worldCamera != camera && OwnsCanvas)
|
||||
canvas.worldCamera = camera;
|
||||
return camera;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if(Application.isEditor && Application.isPlaying == false)
|
||||
{
|
||||
ApplyTextPosition();
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 ProjectPointOnPlane(Vector3 planeNormal, Vector3 planePoint, Vector3 point)
|
||||
{
|
||||
planeNormal.Normalize();
|
||||
float distance = -Vector3.Dot(planeNormal.normalized, (point - planePoint));
|
||||
return point + planeNormal * distance;
|
||||
}
|
||||
|
||||
void CalculatePlane(Camera cam, RectTransform transform, out Vector3 center, out Vector3 normal)
|
||||
{
|
||||
mRect.GetWorldCorners(mPlaneCorners);
|
||||
center = new Vector3();
|
||||
for (int i = 0; i < mPlaneCorners.Length; i++)
|
||||
{
|
||||
center += mPlaneCorners[i];
|
||||
}
|
||||
center *= 0.25f;
|
||||
Vector3 a = mPlaneCorners[1] - mPlaneCorners[0];
|
||||
Vector3 b = mPlaneCorners[2] - mPlaneCorners[0];
|
||||
normal = Vector3.Cross(a, b).normalized;
|
||||
}
|
||||
|
||||
public void ApplyTextPosition()
|
||||
{
|
||||
Camera = EnsureCamera();
|
||||
if (mCanvas == null)
|
||||
return;
|
||||
float scale = 1f;
|
||||
if (Camera != null)
|
||||
{
|
||||
if (mParent != null && (mParent.VRSpaceText || mParent.PaperEffectText) && OwnsCanvas)
|
||||
{
|
||||
Vector3 difVector = new Vector3(transform.position.x, 0, transform.position.z) - new Vector3(Camera.transform.position.x, 0, Camera.transform.position.z);
|
||||
if (difVector != Vector3.zero && mParent.PaperEffectText == false)
|
||||
{
|
||||
mCanvas.transform.rotation = Quaternion.LookRotation(difVector, Vector3.up);
|
||||
}
|
||||
|
||||
// mCanvas.transform.rotation = Camera.transform.rotation;
|
||||
mCanvas.transform.localScale = new Vector3(mParent.VRSpaceScale, mParent.VRSpaceScale, mParent.VRSpaceScale);
|
||||
}
|
||||
|
||||
|
||||
if (mPrivateParent != null && mPrivateParent.KeepOrthoSize)
|
||||
{
|
||||
|
||||
if (Camera != null && Camera.orthographic && Camera.orthographicSize > 0.1f)
|
||||
{
|
||||
scale = 5f / Camera.orthographicSize;
|
||||
}
|
||||
}
|
||||
scale *= mInnerScale;
|
||||
if (Mathf.Abs(mPrevScale - scale) > 0.001f)
|
||||
{
|
||||
mInvalidated = false;
|
||||
}
|
||||
mPrevScale = scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mParent == null || mParent.IsCanvas == false)
|
||||
return;
|
||||
}
|
||||
//if (mInvalidated == false)
|
||||
// {
|
||||
mText.RemoveAll(x =>
|
||||
{
|
||||
if (x == null)
|
||||
return true;
|
||||
BillboardText billboard = x;
|
||||
if (mInvalidated == false || billboard.transform.hasChanged || mCanvas.transform.hasChanged)
|
||||
{
|
||||
var rect = billboard.Rect;
|
||||
if (rect != null)
|
||||
rect.transform.position = billboard.transform.position;
|
||||
else
|
||||
billboard.UIText.transform.position = billboard.transform.position;
|
||||
float yScale = (billboard.YMirror == true) ? -1f : 1f;
|
||||
billboard.UIText.transform.localScale = new Vector3(billboard.Scale * scale, yScale* billboard.Scale * scale, 1f);
|
||||
billboard.transform.hasChanged = false;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
mInvalidated = true;
|
||||
|
||||
// }
|
||||
return;
|
||||
//}
|
||||
/* Canvas canvas = SafeCanvas;
|
||||
if (mParent != null)
|
||||
{
|
||||
Camera = mParent.TextCamera;
|
||||
PlaneDistance = mParent.TextIdleDistance;
|
||||
canvas.planeDistance = PlaneDistance;
|
||||
}
|
||||
|
||||
Camera cam = EnsureCamera();
|
||||
if (cam == null)
|
||||
{
|
||||
if (mWarn == false)
|
||||
Debug.LogWarning("Chart Warning: No main camera set , please set the Chart's camera using \"TextCamera\" in the inspector");
|
||||
mWarn = true;
|
||||
return;
|
||||
}
|
||||
mWarn = false;
|
||||
Vector3 planeCenter;
|
||||
Vector3 planeNormal;
|
||||
CalculatePlane(cam, mRect, out planeCenter, out planeNormal);
|
||||
//Debug.DrawLine(planeCenter, planeCenter+ planeNormal,Color.red);
|
||||
foreach (BillboardText text in mText)
|
||||
{
|
||||
// RectTransformUtility.
|
||||
Vector3 point = text.transform.position;
|
||||
Vector3 pointOnPlane = ProjectPointOnPlane(planeNormal, planeCenter, text.transform.position);
|
||||
//Debug.DrawLine(point, pointOnPlane);
|
||||
Vector3 worldVec = (pointOnPlane - point);
|
||||
Vector3 vec = mRect.worldToLocalMatrix * worldVec;
|
||||
float dist = vec.magnitude;
|
||||
if (Vector3.Dot(worldVec, cam.transform.forward) > 0)
|
||||
dist = -dist;
|
||||
|
||||
Vector2 viewport = cam.WorldToViewportPoint(pointOnPlane);
|
||||
// Debug.DrawLine(viewport, pointOnPlane);
|
||||
// Vector3 anchored = new Vector3(
|
||||
// (mRect.sizeDelta.x * viewport.x) - (mRect.sizeDelta.x * mRect.anchorMin.x),
|
||||
// (mRect.sizeDelta.y * viewport.y) - (mRect.sizeDelta.y * mRect.anchorMin.y),
|
||||
// dist);
|
||||
Vector2 screen = RectTransformUtility.WorldToScreenPoint(cam,pointOnPlane);
|
||||
Vector2 pos;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(mRect, screen, cam, out pos);
|
||||
// float scaleDist = mPlaneDistance + worldVec.magnitude;
|
||||
// if (scaleDist <= 0)
|
||||
// scaleDist = 0.1f;
|
||||
// float scale = scaleDist/ mPlaneDistance;
|
||||
//text.Rect.localScale = new Vector3(scale, scale, 1f);
|
||||
text.Rect.localPosition = new Vector3(pos.x, pos.y , dist);
|
||||
}*/
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
//ApplyTextPosition();
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Text/TextController.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Text/TextController.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8c8bf670921e114bbea10f451c86392
|
||||
timeCreated: 1473942199
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
111
Assets/Chart And Graph/Script/Text/TextDirection.cs
Normal file
111
Assets/Chart And Graph/Script/Text/TextDirection.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class TextDirection : MonoBehaviour
|
||||
{
|
||||
public Material PointMaterial = null;
|
||||
public Material LineMaterial = null;
|
||||
|
||||
public float Length = 20f;
|
||||
public float Gap = 5f;
|
||||
public float Thickness = 2f;
|
||||
public float PointSize = 10f;
|
||||
|
||||
public CanvasLines Lines = null;
|
||||
public CanvasLines Point = null;
|
||||
public MonoBehaviour Text = null;
|
||||
|
||||
private Transform relativeTo;
|
||||
private Transform relativeFrom;
|
||||
private TextController controller;
|
||||
public void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void SetTextController (TextController control)
|
||||
{
|
||||
controller = control;
|
||||
}
|
||||
|
||||
public void SetRelativeTo(Transform from,Transform to)
|
||||
{
|
||||
relativeTo = to;
|
||||
relativeFrom = from;
|
||||
|
||||
}
|
||||
|
||||
public void LateUpdate()
|
||||
{
|
||||
if (relativeFrom == null || relativeTo == null || controller == null || controller.Camera == null)
|
||||
return;
|
||||
Vector3 dir = (relativeTo.position - relativeFrom.position).normalized * Length;
|
||||
Quaternion inverse = Quaternion.Inverse(controller.Camera.transform.rotation);
|
||||
dir = inverse * dir;
|
||||
SetDirection(dir);
|
||||
}
|
||||
|
||||
public void SetDirection(float angle)
|
||||
{
|
||||
SetDirection(ChartCommon.FromPolar(angle, Length));
|
||||
}
|
||||
|
||||
private void SetDirection(Vector3 dir)
|
||||
{
|
||||
//Vector3 dir = ChartCommon.FromPolar(angle, Length);
|
||||
float sign = Mathf.Sign(dir.x);
|
||||
Vector3 dirAdd = new Vector3(1f, 0f, 0f) * sign * Length;
|
||||
Vector3 gapAdd = new Vector3(1f, 0f, 0f) * sign * Gap;
|
||||
if (LineMaterial != null)
|
||||
{
|
||||
List<CanvasLines.LineSegement> segments = new List<CanvasLines.LineSegement>();
|
||||
segments.Add(new CanvasLines.LineSegement(new Vector3[] { Vector3.zero, dir, dir + dirAdd }));
|
||||
Lines.Thickness = Thickness;
|
||||
Lines.Tiling = 1f;
|
||||
Lines.material = LineMaterial;
|
||||
Lines.SetLines(segments);
|
||||
}
|
||||
|
||||
if(PointMaterial != null)
|
||||
{
|
||||
List<CanvasLines.LineSegement> segments = new List<CanvasLines.LineSegement>();
|
||||
segments.Add(new CanvasLines.LineSegement(new Vector3[] { Vector3.zero}));
|
||||
Point.MakePointRender(PointSize);
|
||||
Point.material = PointMaterial;
|
||||
Point.SetLines(segments);
|
||||
}
|
||||
|
||||
Vector2 anchor = new Vector2( 0.5f , 0.5f);
|
||||
Vector2 pivot = new Vector2((sign > 0f) ? 0f : 1f, 0.5f);
|
||||
|
||||
var rect = Text.GetComponent<RectTransform>();
|
||||
if (rect != null)
|
||||
{
|
||||
rect.anchorMin = anchor;
|
||||
rect.anchorMax = anchor;
|
||||
rect.pivot = pivot;
|
||||
var t = Text.GetComponent<Text>();
|
||||
if (t != null)
|
||||
t.alignment = (sign > 0f) ? TextAnchor.MiddleLeft : TextAnchor.MiddleRight;
|
||||
else
|
||||
{
|
||||
ChartCommon.DoTextSign(Text, sign);
|
||||
|
||||
}
|
||||
rect.anchoredPosition = dir + dirAdd + gapAdd;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Direction text must contain a rect transform");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Text/TextDirection.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Text/TextDirection.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c607f6d5dbf90a943bd7332a6fb04bfd
|
||||
timeCreated: 1490546073
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
130
Assets/Chart And Graph/Script/Text/TextFormatting.cs
Normal file
130
Assets/Chart And Graph/Script/Text/TextFormatting.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// text formatting for an item label
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TextFormatting : IInternalSettings
|
||||
{
|
||||
|
||||
[SerializeField]
|
||||
private string prefix = "";
|
||||
|
||||
[SerializeField]
|
||||
private string suffix = "";
|
||||
|
||||
[SerializeField]
|
||||
private string customFormat = "";
|
||||
|
||||
public string Suffix
|
||||
{
|
||||
get { return suffix; }
|
||||
set
|
||||
{
|
||||
suffix = value;
|
||||
RaiseOnUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public string Prefix
|
||||
{
|
||||
get { return prefix; }
|
||||
set
|
||||
{
|
||||
prefix = value;
|
||||
RaiseOnUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomFormat
|
||||
{
|
||||
get { return customFormat; }
|
||||
set
|
||||
{
|
||||
customFormat = value;
|
||||
RaiseOnUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private event EventHandler OnDataUpdate;
|
||||
private event EventHandler OnDataChanged;
|
||||
|
||||
protected virtual void RaiseOnChanged()
|
||||
{
|
||||
if (OnDataChanged != null)
|
||||
OnDataChanged(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void RaiseOnUpdate()
|
||||
{
|
||||
if (OnDataUpdate != null)
|
||||
OnDataUpdate(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#region Intenal Use
|
||||
event EventHandler IInternalSettings.InternalOnDataUpdate
|
||||
{
|
||||
add
|
||||
{
|
||||
OnDataUpdate += value;
|
||||
}
|
||||
|
||||
remove
|
||||
{
|
||||
OnDataUpdate -= value;
|
||||
}
|
||||
}
|
||||
|
||||
event EventHandler IInternalSettings.InternalOnDataChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
OnDataChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
OnDataChanged -= value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private string FormatKeywords(string str,string category,string group)
|
||||
{
|
||||
if (str.Contains("<?") == false && str.Contains("\\n") == false)
|
||||
return str;
|
||||
|
||||
return str.Replace("<?category>", category).Replace("<?group>",group).Replace("\\n",Environment.NewLine);
|
||||
}
|
||||
private void FormatKeywords(StringBuilder builder, string category, string group)
|
||||
{
|
||||
builder.Replace("<?category>", category).Replace("<?group>", group).Replace("\\n", Environment.NewLine);
|
||||
}
|
||||
private string ValidString(string str)
|
||||
{
|
||||
if (str == null)
|
||||
return "";
|
||||
return str;
|
||||
}
|
||||
public void Format(StringBuilder builder,string data, string category, string group)
|
||||
{
|
||||
builder.Length = 0;
|
||||
builder.Append(ValidString(Prefix));
|
||||
builder.Append(data);
|
||||
builder.Append(ValidString(Suffix));
|
||||
FormatKeywords(builder, category, group);
|
||||
}
|
||||
public string Format(string data,string category,string group)
|
||||
{
|
||||
string tmp = ValidString(Prefix) + data + ValidString(Suffix);
|
||||
return FormatKeywords(tmp, category, group);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Text/TextFormatting.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Text/TextFormatting.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9b10d4f93b0dc3428a5b7419eb4e2f7
|
||||
timeCreated: 1480163532
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user