Added a script that starts the game & saves player name on Enter press

This commit is contained in:
alilas2 2022-07-04 20:52:22 +02:00
parent 7b3ba79f4a
commit eaf5b09de3
5 changed files with 385 additions and 21 deletions

View File

@ -650,7 +650,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 44.2725, y: -4.9025}
m_AnchoredPosition: {x: 44.27249, y: -4.9025}
m_SizeDelta: {x: -171.455, y: -40.195}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &637316601
@ -3062,7 +3062,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 44.2725, y: -4.902499}
m_AnchoredPosition: {x: 44.27249, y: -4.9025}
m_SizeDelta: {x: -171.455, y: -40.195}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1915001221
@ -3186,3 +3186,48 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2081700205}
m_CullTransparentMesh: 1
--- !u!1 &2118642211
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2118642213}
- component: {fileID: 2118642212}
m_Layer: 0
m_Name: StartOnEnter
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2118642212
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2118642211}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96a87231833611469d48acc567a6d5c, type: 3}
m_Name:
m_EditorClassIdentifier:
saveName:
inputText: {fileID: 637316601}
--- !u!4 &2118642213
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2118642211}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.17102379, y: -1.2999886, z: -1.2975713}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

22
Assets/StartOnEnter.cs Normal file
View File

@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class StartOnEnter : MonoBehaviour
{
public string saveName;
public Text inputText;
void Update()
{
if (Input.GetKey(KeyCode.KeypadEnter) || Input.GetKey(KeyCode.Return))
{
saveName = inputText.text;
PlayerPrefs.SetString("name", saveName);
SceneManager.LoadScene(6);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e96a87231833611469d48acc567a6d5c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

@ -18,22 +18,22 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c72111f19352f223d667d6d1a1226ece42776f7e93ffdfe
flags: 0
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c72111f19352f223d667d6d0a1532f0e1372ce7f518e8ea3f7129370bfb25
value: 22424703114646680e0b0227036c72111f19352f223d667d6d0a123df6f23b34f1a923e7ee2e26
flags: 0
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c72111f19352f223d667d6d0a123df6f23b34f1a923e7ee2e26
flags: 0
RecentlyUsedScenePath-6:
value: 22424703114646680e0b0227036c72111f19352f223d667d6d0a123df6f23b34f1a923e7ee2e26
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0
RecentlyUsedScenePath-7:
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
flags: 0
RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021
flags: 0
RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
value: 22424703114646680e0b0227036c72111f19352f223d667d6d0a1532f0e1372ce7f518e8ea3f7129370bfb25
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650