Created
July 4, 2018 03:11
-
-
Save ousttrue/c44073c07a06629a322d1422aab31018 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class CubeBar : MonoBehaviour | |
{ | |
[SerializeField, Range(0, 1)] | |
float m_value; | |
// キューブ付ける | |
[SerializeField] | |
GameObject m_bar; | |
[SerializeField] | |
Vector3 m_size = Vector3.one; | |
private void OnValidate() | |
{ | |
if (m_value == 0) | |
{ | |
m_bar.SetActive(false); | |
} | |
else | |
{ | |
m_bar.SetActive(true); | |
m_bar.transform.localScale = new Vector3(m_value * m_size.x, 1.0f * m_size.y, 1.0f * m_size.z); | |
m_bar.transform.localPosition = new Vector3(m_bar.transform.localScale.x * 0.5f, 0, 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment