// Start is called before the first frame update void Start() { idleState = gameObject.GetComponent <NewsUIIdleState>(); entryState = gameObject.GetComponent <NewsUIEntryState>(); for (int i = 0; i < 5; i++) { var newsUI = newsUIs[i].GetComponent <NewsUI>(); // StateをIdleにする newsUI.IdleStart(); } }
private void Awake() { // 各ステートを初期化 entryState = GetComponent <NewsUIEntryState>(); exitState = GetComponent <NewsUIExitState>(); idleState = GetComponent <NewsUIIdleState>(); showState = GetComponent <NewsUIShowState>(); newsUIContext = new NewsUIContext(); ReadTextParameter(); }
// ExitStateのEntry処理をする関数 public void StartExit() { // 初期化処理 idleState = GetComponent <NewsUIIdleState>(); var newsUIRect = gameObject.GetComponent <RectTransform>(); // スタート地点を設定 startPos = newsUIRect.localPosition; // 移動先を計算 float targetPosX = (-Screen.width / 2f) + (-newsUIRect.sizeDelta.x / 2f); float targetPosY = newsUIRect.localPosition.y; float targetPosZ = newsUIRect.localPosition.z; targetPos = new Vector3(targetPosX, targetPosY, targetPosZ);; // スタート地点から目標地点までの方向を計算 var moveVec = targetPos - startPos; // 正規化 normalMoveVec = moveVec.normalized; // スタート地点から目標地点までの距離を計算 distance = Vector3.Distance(startPos, targetPos); nowDistance = 0f; }