本文整理汇总了C#中Slider.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Slider.GetComponent方法的具体用法?C# Slider.GetComponent怎么用?C# Slider.GetComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slider
的用法示例。
在下文中一共展示了Slider.GetComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
void Awake()
{
#region Initialize stuff
currentHealth = Hp;
HealthBar = this.GetComponentInChildren<Canvas>();
HealthBar.name = "HealthBar_" + this.gameObject.name;
//HealthBar.transform.parent = null;
HealthBar.transform.SetParent(null, false);
m_hHpSlider = HealthBar.GetComponentInChildren<Slider>();
m_hSliderRectTransform = m_hHpSlider.GetComponent<RectTransform>();
//m_hDisassembler = GetComponent<MeshDisassembler>();
m_hRigidbody = GetComponent<Rigidbody>();
m_hController = GetComponent<IControllerPlayer>() as MonoBehaviour;
m_hProvider = GetComponent<InputProviderPCStd>();
m_hWeapon = GetComponent<IWeapon>() as MonoBehaviour;
m_hRenderers = new List<Renderer>(GetComponents<Renderer>());
m_hRenderers.AddRange(GetComponentsInChildren<Renderer>());
m_hColliders = new List<Collider>(GetComponents<Collider>());
m_hColliders.AddRange(GetComponentsInChildren<Collider>());
m_hBomb = GetComponent<DeathBomb>();
m_hAudioCtrl = this.GetComponent<MadMaxCarAudio>();
impactCoolDownActors = new LinkedList<MadMaxActor>();
PlayableCenterOfMass = m_hRigidbody.centerOfMass;
wheels = GetComponent<ControllerWheels>();
//dmgImgMGR = GameManager.Instance.GetComponentInChildren<DMGImageMGR>();
CanTakeDamage = true;
#endregion
if (HpBarMode == HealthBarMode.WorldSpace)
{
HealthBar.renderMode = RenderMode.WorldSpace;
}
else
{
HealthBar.renderMode = RenderMode.ScreenSpaceOverlay;
}
}
示例2: Start
void Start()
{
// Instantiate our health bar GUI slider.
_healthUI = Instantiate(HealthBarPrefab, gameObject.transform.position, Quaternion.identity) as Slider;
_healthUI.gameObject.transform.SetParent(_healthbarManager.transform, false);
_healthUI.GetComponent<Healthbar>().Target = gameObject;
_healthUI.GetComponent<Healthbar>().YOffset = GetComponent<CapsuleCollider>().height+HealthbarOffset;
_healthUI.gameObject.SetActive(false);
//Only do on first take damage???
_healthUI.gameObject.SetActive(true);
}
示例3: Start
void Start()
{
//get my slider and my inputfield
input_slider = gameObject.GetComponentInChildren<Slider>();
input_textField = gameObject.GetComponentInChildren<InputField>();
//adjust and modify our min/max for this given variable
input_slider.GetComponent<Slider>().maxValue = MaxInputValue;
input_slider.GetComponent<Slider>().minValue = MinInputValue;
input_slider.GetComponent<Slider>().value = StartingValue;
variableValue = StartingValue;
UpdateTextBox(StartingValue);
}
示例4: PlayCurrentMoment
/* Diagram for PlayCurrentMoment + MomentTimer
float t = 0f;
PlayCurrentMoment() ------> StartMomentTimer(t, button, slider) ----> (t < currentMoment.Duration) ? yes : no ----> Finish
^ |
| v
--------------------- t = t + time.deltaTime -----------------------
*/
IEnumerator MomentTimer(float momentTime, Button button, Slider slider)
{
if(momentTime >= 0)
{
slider.transform.localScale = Vector3.one;
button.image.color = Color.yellow;
}
slider.GetComponent<RectTransform>().sizeDelta = button.GetComponent<RectTransform>().rect.size;
slider.value = slider.maxValue - momentTime;
yield return null;
if(momentTime >= slider.maxValue)
{
slider.transform.localScale = Vector3.zero;
slider.value = slider.minValue;
button.image.color = Color.white;
}
else
{
IEnumerator momentTimer = MomentTimer(momentTime + Time.deltaTime, button, slider);
StartCoroutine (momentTimer);
}
}