huge change, new desig wip
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using WindowsInput.Native;
|
||||
|
||||
public class KeyDropdownManager : MonoBehaviour
|
||||
{
|
||||
TMP_Dropdown Dropdown;
|
||||
void Start()
|
||||
{
|
||||
Dropdown = GetComponent<TMP_Dropdown>();
|
||||
PopulateList();
|
||||
}
|
||||
void PopulateList()
|
||||
{
|
||||
string[] enumNames = Enum.GetNames(typeof(VirtualKeyCode));
|
||||
List<string> keyNames = new List<string>(enumNames);
|
||||
Dropdown.AddOptions(keyNames);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dc3809278e8e6344b8891c35a1896ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
using WindowsInput.Native;
|
||||
|
||||
public class PanelButton : MonoBehaviour
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
public static extern uint MapVirtualKey(uint uCode, uint uMapType);
|
||||
[DllImport("user32.dll")]
|
||||
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
|
||||
|
||||
public event Action ButtonPressed;
|
||||
public event Action ButtonReleased;
|
||||
|
||||
public VirtualKeyCode key;
|
||||
public VirtualKeyCode key2;
|
||||
|
||||
public bool isToggle;
|
||||
public bool doesBeep;
|
||||
|
||||
public bool isOn;
|
||||
private int _insideColliderCount = 0;
|
||||
|
||||
private Renderer cr;
|
||||
//public GameObject camera; // just generating warnings lmao
|
||||
public AudioSource audioSrc;
|
||||
|
||||
void Start()
|
||||
{
|
||||
cr = GetComponent<Renderer>();
|
||||
|
||||
if (isToggle)
|
||||
{
|
||||
// initialize toggle state
|
||||
ButtonPress();
|
||||
ButtonRelease();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
_insideColliderCount += 1;
|
||||
ButtonPress();
|
||||
if (doesBeep)
|
||||
audioSrc?.Play();
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
_insideColliderCount = Mathf.Clamp(_insideColliderCount - 1, 0, _insideColliderCount);
|
||||
|
||||
if (_insideColliderCount == 0)
|
||||
{
|
||||
ButtonRelease();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonPress()
|
||||
{
|
||||
ButtonPressed?.Invoke();
|
||||
if (isToggle)
|
||||
{
|
||||
if (!isOn)
|
||||
{
|
||||
cr.material.color = Color.green;
|
||||
keybd_event(System.Convert.ToByte(key2), (byte)MapVirtualKey((uint)key2, 0), 2, UIntPtr.Zero);
|
||||
keybd_event(System.Convert.ToByte(key), (byte)MapVirtualKey((uint)key, 0), 0, UIntPtr.Zero);
|
||||
isOn = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cr.material.color = Color.red;
|
||||
keybd_event(System.Convert.ToByte(key), (byte)MapVirtualKey((uint)key, 0), 2, UIntPtr.Zero);
|
||||
keybd_event(System.Convert.ToByte(key2), (byte)MapVirtualKey((uint)key2, 0), 0, UIntPtr.Zero);
|
||||
isOn = false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
cr.material.color = Color.white;
|
||||
keybd_event(System.Convert.ToByte(key), (byte)MapVirtualKey((uint)key, 0), 0, UIntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRelease()
|
||||
{
|
||||
ButtonReleased?.Invoke();
|
||||
keybd_event(System.Convert.ToByte(key), (byte)MapVirtualKey((uint)key, 0), 2, UIntPtr.Zero);
|
||||
keybd_event(System.Convert.ToByte(key2), (byte)MapVirtualKey((uint)key2, 0), 2, UIntPtr.Zero);
|
||||
if (!isToggle)
|
||||
cr.material.color = Color.gray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 259f9860c17d7be48be056658ffa3d1e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TabManager : MonoBehaviour
|
||||
{
|
||||
public GameObject Tab1Object;
|
||||
public GameObject Tab2Object;
|
||||
void Start()
|
||||
{
|
||||
OnFirstTabClick();
|
||||
}
|
||||
public void OnFirstTabClick()
|
||||
{
|
||||
Tab1Object.SetActive(true);
|
||||
Tab2Object.SetActive(false);
|
||||
}
|
||||
public void OnSecondTabClick()
|
||||
{
|
||||
Tab1Object.SetActive(false);
|
||||
Tab2Object.SetActive(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0be7d3822381814d8b27523d4f9a550
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user