Init
This commit is contained in:
65
Assets/ThirdParty/Lana Studio/Casual RPG VFX/Demo/Scripts/ObjectsSwitcher.cs
vendored
Normal file
65
Assets/ThirdParty/Lana Studio/Casual RPG VFX/Demo/Scripts/ObjectsSwitcher.cs
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Sveta
|
||||
{
|
||||
|
||||
[System.Serializable]
|
||||
public class UnityEventString : UnityEvent<string>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class ObjectsSwitcher : MonoBehaviour
|
||||
{
|
||||
public UnityEventString outputName;
|
||||
|
||||
public List<GameObject> list;
|
||||
private int index = 0;
|
||||
|
||||
public void Switch(int delta)
|
||||
{
|
||||
index += delta;
|
||||
|
||||
if (index > list.Count - 1)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = list.Count - 1;
|
||||
}
|
||||
|
||||
|
||||
SwitchTo(index);
|
||||
}
|
||||
|
||||
private void SwitchTo(int _index) {
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
list[i].SetActive(i == _index);
|
||||
}
|
||||
|
||||
outputName?.Invoke(list[_index].name);
|
||||
|
||||
}
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
/*
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
list[i].gameObject.SetActive(false);
|
||||
}
|
||||
list[0].SetActive(true);
|
||||
*/
|
||||
|
||||
SwitchTo(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/Lana Studio/Casual RPG VFX/Demo/Scripts/ObjectsSwitcher.cs.meta
vendored
Normal file
11
Assets/ThirdParty/Lana Studio/Casual RPG VFX/Demo/Scripts/ObjectsSwitcher.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 206d4fc2e7c1b054dab4295a740143b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Assets/ThirdParty/Lana Studio/Casual RPG VFX/Demo/Scripts/_InputKeyBoard.cs
vendored
Normal file
56
Assets/ThirdParty/Lana Studio/Casual RPG VFX/Demo/Scripts/_InputKeyBoard.cs
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
|
||||
|
||||
[AddComponentMenu("1Enwer/Input/_KeyBoard")]
|
||||
public class _InputKeyBoard : MonoBehaviour
|
||||
{
|
||||
public PressType pressType = PressType.GetKeyDown;
|
||||
public KeyCodeEvent[] keyBoardGetKey;
|
||||
|
||||
public enum PressType
|
||||
{
|
||||
GetKey,
|
||||
GetKeyDown,
|
||||
GetKeyUp
|
||||
}
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class KeyCodeEvent
|
||||
{
|
||||
public KeyCode keyCode;
|
||||
public UnityEvent function;
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
for (int i = 0; i < keyBoardGetKey.Length; i++)
|
||||
{
|
||||
if (KeyBoardIsPressed(pressType, keyBoardGetKey[i].keyCode))
|
||||
{
|
||||
keyBoardGetKey[i].function.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool KeyBoardIsPressed(PressType _pressType, KeyCode keycode)
|
||||
{
|
||||
switch (_pressType)
|
||||
{
|
||||
case PressType.GetKey:
|
||||
return Input.GetKey(keycode);
|
||||
case PressType.GetKeyDown:
|
||||
return Input.GetKeyDown(keycode);
|
||||
case PressType.GetKeyUp:
|
||||
return Input.GetKeyUp(keycode);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/Lana Studio/Casual RPG VFX/Demo/Scripts/_InputKeyBoard.cs.meta
vendored
Normal file
11
Assets/ThirdParty/Lana Studio/Casual RPG VFX/Demo/Scripts/_InputKeyBoard.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62632f272f383f04984817342239ea70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user