我想根据输入字段中键入的值统一打开一个场景。
例如:
如果用户输入4,将加载场景名称编号 如果用户输入5,则将加载场景名称number1
答案 0 :(得分:0)
您必须调用SceneManager.LoadScene,这是引用:https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html
为了使类似的东西起作用,您需要阅读输入内容。可以通过以下输入字段来完成:https://docs.unity3d.com/ScriptReference/UI.InputField-text.html
或者一个下拉列表:https://docs.unity3d.com/Manual/script-Dropdown.html
然后设置一个按钮,将解析输入并调用SceneManager.LoadScene函数。
答案 1 :(得分:0)
要获取更改后的文本事件,可以在文本字段https://docs.unity3d.com/Manual/script-InputField.html上使用OnValueChange属性
要加载场景,请使用SceneManager.LoadScene(“ SceneName”)方法https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html
答案 2 :(得分:0)
您可以通过引用InputField并调用
#this is the first method I have tried
import pandas as pd
import numpy as np
from google.colab import files
uploaded = files.upload()
# df = pd.read_csv('/content/drive/My Drive/allTheaterDataV2.csv')
import io
df = pd.read_csv(io.BytesIO(uploaded['allTheaterDataV2.csv']))
# Daset is now stored in a Pandas Dataframe
#create list that contains the specific season that we want to reference
# print(df)
data = pd.DataFrame(allTheaterDataV2)
dataindex = [20082009, 20102011, 20112012, 20122013, 20132014, 20142015]
print(dataindex)
df.loc['total',:] = df.sum(axis=0)
print(df.loc[1:42, ['ASIAM','AFRAM','LAT','CAU','OTH']].sum())
# The second method I have tried is included below
for i in dataindex:
# create a new data frame that stores the data per year
hold_ASIAM = df[df.index == i]
# allows for data for each season to be contained together
ETHtotalASIAM = df['ASIAM'].sum()
hold_ASIAM.append(ETHtotalASIAM)
print(hold_ASIAM)
来自按钮事件
ChangeSceneBasedOnInputField()