Skip to content

Commit 8417f86

Browse files
committed
revert
1 parent db51706 commit 8417f86

File tree

793 files changed

+26674
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

793 files changed

+26674
-0
lines changed

Assets/JCSUnity/Scripts/UI/Bar.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/**
2+
* $File: JCS_3DLiquidBarText.cs $
3+
* $Date: $
4+
* $Revision: $
5+
* $Creator: Jen-Chieh Shen $
6+
* $Notice: See LICENSE.txt for modification and distribution information
7+
* Copyright (c) 2016 by Shen, Jen-Chieh $
8+
*/
9+
using UnityEngine;
10+
using UnityEngine.UI;
11+
using MyBox;
12+
13+
namespace JCSUnity
14+
{
15+
/// <summary>
16+
/// Object GUI which will do like the counter show.
17+
/// </summary>
18+
[RequireComponent(typeof(JCS_3DLiquidBar))]
19+
public class JCS_3DLiquidBarText : MonoBehaviour
20+
{
21+
/* Variables */
22+
23+
// Counter with the liquid bar?
24+
private JCS_3DLiquidBar mLiquidBar = null;
25+
26+
[Separator("Runtime Variables (JCS_3DLiquidBarText)")]
27+
28+
[Tooltip("Text to do the effect.")]
29+
[SerializeField]
30+
private Text mCounterText = null;
31+
32+
[Tooltip("This give the transformation for the Word space to Canvas space.")]
33+
[SerializeField]
34+
private Transform mCounterTextWorldTransform = null;
35+
36+
[Header("- Text")]
37+
38+
[Tooltip("Text Render maxinum of the liquid bar value.")]
39+
[SerializeField]
40+
private Text mFullText = null;
41+
42+
[Tooltip("This give the transformation for the Word space to Canvas space.")]
43+
[SerializeField]
44+
private Transform mFullTextWorldTransform = null;
45+
46+
[Header("- Sprite")]
47+
48+
[Tooltip("Sprite Render the current value of the liquid bar.")]
49+
[SerializeField]
50+
private JCS_DeltaNumber mCounterTextSprite = null;
51+
52+
[Tooltip("Sprite Render the max value of the liquid bar.")]
53+
[SerializeField]
54+
private JCS_DeltaNumber mFullTextSprite = null;
55+
56+
/* Setter & Getter */
57+
58+
public JCS_DeltaNumber CounterTextSprite { get { return this.mCounterTextSprite; } set { this.mCounterTextSprite = value; } }
59+
public JCS_DeltaNumber FullTextSprite { get { return this.mFullTextSprite; } set { this.mFullTextSprite = value; } }
60+
61+
/* Functions */
62+
63+
private void Awake()
64+
{
65+
this.mLiquidBar = this.GetComponent<JCS_3DLiquidBar>();
66+
}
67+
68+
private void LateUpdate()
69+
{
70+
FitCanvas();
71+
72+
DoTextRender();
73+
}
74+
75+
/// <summary>
76+
/// Find the value and set the text to value.
77+
/// </summary>
78+
private void DoTextRender()
79+
{
80+
if (mCounterText != null)
81+
mCounterText.text = ((int)mLiquidBar.GetCurrentValue()).ToString();
82+
83+
if (mFullText != null)
84+
mFullText.text = mLiquidBar.MaxValue.ToString();
85+
86+
if (mCounterTextSprite != null)
87+
mCounterTextSprite.UpdateNumber((int)mLiquidBar.GetCurrentValue());
88+
89+
if (mFullTextSprite != null)
90+
mFullTextSprite.UpdateNumber((int)mLiquidBar.MaxValue);
91+
}
92+
93+
/// <summary>
94+
/// Make the Canvas space text fit in world space.
95+
/// </summary>
96+
private void FitCanvas()
97+
{
98+
if (mCounterText != null && mCounterTextWorldTransform != null)
99+
{
100+
mCounterText.rectTransform.anchoredPosition = JCS_Camera.main.WorldToCanvasSpace(this.mCounterTextWorldTransform.position);
101+
}
102+
103+
if (mFullText != null && mFullTextWorldTransform != null)
104+
{
105+
mFullText.rectTransform.anchoredPosition = JCS_Camera.main.WorldToCanvasSpace(this.mFullTextWorldTransform.position);
106+
}
107+
}
108+
}
109+
}

Assets/JCSUnity/Scripts/UI/Bar/JCS_3DLiquidBarText.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)