/// <summary> /// Make single log message on the screen. /// </summary> /// <param name="message"></param> public void SendLogMessage(string message) { // get one log text from the pool JCS_LogText logText = mLogTextPool.ExecuteOneFromPool(); // all pool active? if (logText == null) { return; } UpdateSpace(); mRenderLogText.push(logText); Vector3 newPos = logText.SimpleTrackAction.TargetPosition; // set back to position. // NOTE(jenchieh): 不太懂這邊的原理... newPos.y = 0.0f; logText.SimpleTrackAction.TargetPosition = newPos; logText.SimpleTrackAction.LocalPosition = newPos; // this will set the log text active, // so it wont be reuse until is fade out. logText.Execute(message); }
/// <summary> /// Update all current active log messages' spacing. /// </summary> /// <param name="spaces"></param> public void UpdateSpace(int spaces = 1) { JCS_LogText logText = null; for (int index = 0; index < mRenderLogText.length; ++index) { logText = mRenderLogText.at(index); logText.SimpleTrackAction.DeltaTargetPosY(mLogSpacing * spaces); } }
//======================================== // Self-Define //------------------------------ //---------------------- // Public Functions //---------------------- // Protected Functions //---------------------- // Private Functions /// <summary> /// Spawn the text pool base on number of handle. /// </summary> private void SpawnTextPool() { if (mLogText == null) { JCS_Debug.LogReminders( "No log text assign in the text pool..."); return; } // NOTE(JenChieh): this might change in // the future. // Get the log system from the // same transfrom/node. JCS_IGLogSystem logSystem = this.GetComponent <JCS_IGLogSystem>(); mLogTexts = new JCS_Vector <JCS_LogText>(mNumberOfHandle); for (int count = 0; count < mNumberOfHandle; ++count) { // spawn a new game object, // and get the component JCS_LogText logText = (JCS_LogText)JCS_Utility.SpawnGameObject(mLogText); // add to array mLogTexts.set(count, logText); // set parent JCS_Utility.SetParentWithoutLosingInfo(logText.transform, this.transform); // NOTE(JenChieh): this might change in // the future. // set the log system if there is one. logText.SetIGLogSystem(logSystem); } }
/// <summary> /// Remove the log message that are outdated. /// </summary> /// <param name="txt"></param> public void RemoveFromRenderVec(JCS_LogText txt) { mRenderLogText.slice(txt); }