chore: Assets 디렉토리 구조 정리 및 네이밍 컨벤션 적용
- Assets/_Game/ 하위로 게임 에셋 통합 - External/ 패키지 벤더별 분류 (Synty, Animations, UI) - 에셋 네이밍 컨벤션 확립 및 적용 (Data_Skill_, Data_SkillEffect_, Prefab_, Anim_, Model_, BT_ 등) - pre-commit hook으로 네이밍 컨벤션 자동 검사 추가 - RESTRUCTURE_CHECKLIST.md 작성 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
117
Assets/External/UI/InterfaceFantasyWarriorHUD/Samples/Scripts/SampleButtonAction.cs
vendored
Normal file
117
Assets/External/UI/InterfaceFantasyWarriorHUD/Samples/Scripts/SampleButtonAction.cs
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
|
||||
//
|
||||
// Use of this software is subject to the terms and conditions of the Synty Studios End User Licence Agreement (EULA)
|
||||
// available at: https://syntystore.com/pages/end-user-licence-agreement
|
||||
//
|
||||
// Sample scripts are included only as examples and are not intended as production-ready.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Synty.Interface.FantasyWarriorHUD.Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes a list of animator actions and toggles a list of game objects on click.
|
||||
/// </summary>
|
||||
public class SampleButtonAction : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
public Button button;
|
||||
public List<GameObject> deactivateObjects;
|
||||
public List<GameObject> toggleObjects;
|
||||
public GameObject activateObject;
|
||||
|
||||
[Header("Parameters")]
|
||||
public List<SampleAnimatorActionData> animatorActions;
|
||||
public float activeTime = 1f;
|
||||
public bool diableButtonWhenActive = false;
|
||||
public bool runOnEnable;
|
||||
public bool applyRandomRotationToActivateObject;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (button == null)
|
||||
{
|
||||
button = GetComponent<Button>();
|
||||
}
|
||||
|
||||
if (button == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
button.onClick.AddListener(OnClick);
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
button = GetComponent<Button>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (runOnEnable)
|
||||
{
|
||||
OnClick();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClick()
|
||||
{
|
||||
foreach (GameObject deactivateObject in deactivateObjects)
|
||||
{
|
||||
if (deactivateObject != null)
|
||||
{
|
||||
deactivateObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(C_ActivateObject());
|
||||
|
||||
foreach (GameObject toggleObject in toggleObjects)
|
||||
{
|
||||
if (toggleObject != null)
|
||||
{
|
||||
toggleObject.SetActive(!toggleObject.activeSelf);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (SampleAnimatorActionData action in animatorActions)
|
||||
{
|
||||
action.Execute();
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator C_ActivateObject()
|
||||
{
|
||||
if (diableButtonWhenActive && button != null)
|
||||
{
|
||||
button.interactable = false;
|
||||
}
|
||||
|
||||
if (activateObject != null)
|
||||
{
|
||||
activateObject.SetActive(true);
|
||||
if (applyRandomRotationToActivateObject)
|
||||
{
|
||||
activateObject.transform.localRotation = Quaternion.Euler(0, 0, Random.Range(0, 360));
|
||||
}
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(activeTime);
|
||||
|
||||
if (diableButtonWhenActive && button != null)
|
||||
{
|
||||
button.interactable = true;
|
||||
}
|
||||
|
||||
if (activateObject != null)
|
||||
{
|
||||
activateObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user