长音符再修复 加入了关卡连接 优化了一些默认加载
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
namespace Assets.VFXPACK_IMPACT_WALLCOEUR.Scripts
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class DropdownController : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] VfxController _vfxController;
|
||||
[SerializeField] TMP_Dropdown _dropdown;
|
||||
|
||||
void Start()
|
||||
{
|
||||
GenerateDropdown();
|
||||
}
|
||||
|
||||
void GenerateDropdown()
|
||||
{
|
||||
List<string> options = new();
|
||||
|
||||
_dropdown.ClearOptions();
|
||||
|
||||
foreach (GameObject vfx in _vfxController.VfxList)
|
||||
{
|
||||
options.Add(vfx.name);
|
||||
}
|
||||
|
||||
_dropdown.AddOptions(options);
|
||||
_dropdown.onValueChanged.AddListener(OnDropdownValueChanged);
|
||||
}
|
||||
|
||||
void OnDropdownValueChanged(int index)
|
||||
{
|
||||
PlayVfx();
|
||||
}
|
||||
|
||||
public void PlayVfx()
|
||||
{
|
||||
_vfxController.Play(_dropdown.value);
|
||||
}
|
||||
|
||||
public void StopVfx()
|
||||
{
|
||||
_vfxController.Stop();
|
||||
}
|
||||
|
||||
public void PreviousVfx()
|
||||
{
|
||||
if (_dropdown.value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_dropdown.value--;
|
||||
_dropdown.RefreshShownValue();
|
||||
}
|
||||
|
||||
public void NextVfx()
|
||||
{
|
||||
if (_dropdown.value == _dropdown.options.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_dropdown.value++;
|
||||
_dropdown.RefreshShownValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c625fffdda2912d4cabfc8cdb4968dd4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 335800
|
||||
packageName: VFX - Impact and Hit - Free
|
||||
packageVersion: 1.0
|
||||
assetPath: Assets/VFXPACK_IMPACT_WALLCOEUR_FreeVersion/Scripts/DropdownController.cs
|
||||
uploadId: 794602
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace Assets.VFXPACK_IMPACT_WALLCOEUR.Scripts
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class VfxController : MonoBehaviour
|
||||
{
|
||||
[Header("Place VFX prefabs here")]
|
||||
[SerializeField] List<GameObject> _vfxList;
|
||||
public List<GameObject> VfxList { get => _vfxList; }
|
||||
|
||||
GameObject _currentVfx;
|
||||
|
||||
public void Play(int index)
|
||||
{
|
||||
if (_currentVfx != null)
|
||||
{
|
||||
Destroy(_currentVfx);
|
||||
}
|
||||
|
||||
_currentVfx = Instantiate(_vfxList[index], Vector3.zero, Quaternion.identity, transform);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (_currentVfx != null)
|
||||
{
|
||||
Destroy(_currentVfx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e2f4b17ef261474f8627657365315db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 335800
|
||||
packageName: VFX - Impact and Hit - Free
|
||||
packageVersion: 1.0
|
||||
assetPath: Assets/VFXPACK_IMPACT_WALLCOEUR_FreeVersion/Scripts/VfxController.cs
|
||||
uploadId: 794602
|
||||
Reference in New Issue
Block a user