Commit 670c47cc authored by mmaluschnig's avatar mmaluschnig
Browse files

added buttons and a script to press the buttons when the corresponding key is pressed

parent 15d48b97
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class KeyPressManager : MonoBehaviour {
public Button qButton;
public Button wButton;
public Button eButton;
public Button rButton;
public Button tButton;
public Button yButton;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
var pointer = new PointerEventData(EventSystem.current);
if (Input.GetKeyDown(KeyCode.Q)){
ExecuteEvents.Execute(qButton.gameObject, pointer, ExecuteEvents.submitHandler);
}
if (Input.GetKeyDown(KeyCode.W))
{
ExecuteEvents.Execute(wButton.gameObject, pointer, ExecuteEvents.submitHandler);
}
if (Input.GetKeyDown(KeyCode.E))
{
ExecuteEvents.Execute(eButton.gameObject, pointer, ExecuteEvents.submitHandler);
}
if (Input.GetKeyDown(KeyCode.R))
{
ExecuteEvents.Execute(rButton.gameObject, pointer, ExecuteEvents.submitHandler);
}
if (Input.GetKeyDown(KeyCode.T))
{
ExecuteEvents.Execute(tButton.gameObject, pointer, ExecuteEvents.submitHandler);
}
if (Input.GetKeyDown(KeyCode.Y))
{
ExecuteEvents.Execute(yButton.gameObject, pointer, ExecuteEvents.submitHandler);
}
}
}
fileFormatVersion: 2
guid: 5d6f3811ec749487c8bd2b388b0bf2ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -5,7 +5,7 @@ using UnityEngine;
public class Note : MonoBehaviour {
public float speed = 0.8f;
public float persistTime = 20;
public float persistTime = 10;
public float bobRate = 5;
public float bobScale = 0.5f;
......@@ -19,10 +19,18 @@ public class Note : MonoBehaviour {
// Update is called once per frame
void Update()
{
//change position
float dy = bobScale * Mathf.Sin(bobRate * Time.time);
transform.Translate(new Vector2(speed,dy + (0.6f * speed)) * Time.deltaTime);
//fade away
float uptime = Time.time - startTime;
SpriteRenderer sprite = GetComponent<SpriteRenderer>();
Color tempColour = sprite.color;
tempColour.a = 1 - (uptime / persistTime);
sprite.color = tempColour;
if (Time.time >= startTime + persistTime)
{
Destroy(gameObject);
......
fileFormatVersion: 2
guid: 0fbe3504ed5384b65ba4c0f6cd8dec8b
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: b08f0e383aca047188d71970815f2520
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment