Skip to content

Instantly share code, notes, and snippets.

@ousttrue
Created July 4, 2018 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ousttrue/c44073c07a06629a322d1422aab31018 to your computer and use it in GitHub Desktop.
Save ousttrue/c44073c07a06629a322d1422aab31018 to your computer and use it in GitHub Desktop.
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