Переменные хранятся в Unity-скриптах следующим образом:
Код: Выделить всё
using Assets.Scripts.Events;
using Assets.Scripts.Utils;
using UnityEngine;
namespace Assets.Scripts
{
public class ScoreManager : CommandMonoBehaviour
{
public int Score;
public void Start()
{
Subscribe(GameEvents.BasketGotMovingObject, OnBasketGotMovingObject);
}
private void OnBasketGotMovingObject(GameEventArgs args)
{
Score = Mathf.Max(0, Score + args.Value.BonusPoints);
GameEvents.ScoreUpdated.Publish(new GameEventArgs(Score));
}
}
}
Функция onCreate в экспортированном проекте выглядит так:
Код: Выделить всё
protected void onCreate (Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
getWindow().takeSurface(null);
setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
getWindow().setFormat(PixelFormat.RGB_565);
mUnityPlayer = new UnityPlayer(this);
if (mUnityPlayer.getSettings ().getBoolean ("hide_status_bar", true))
getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
boolean trueColor8888 = false;
mUnityPlayer.init(glesMode, trueColor8888);
View playerView = mUnityPlayer.getView();
setContentView(playerView);
playerView.requestFocus();
}
Как я могу получить доступ к переменным сценария, таким как int Score?
Подробнее здесь: https://stackoverflow.com/questions/207 ... in-eclipse
Мобильная версия