私はこれがモバイルプラットフォームのためであると仮定しますが、そのはまだ次が考えることができない場合でも:
簡単な解決策は、クリックをブロックするために、あなたのUIでフルスクリーンイメージ(UI /パネル)オブジェクトを作成することです。バックグラウンドプロセスが実行中の場合、このパネルを他のUIの前に表示するためにAnimatorコンポーネント(トリガー付き)を使用します。
public class Loader : MonoBehaviour
{
public static Loader Instance;
Animator m_Animator;
public bool Loading {get; private set;}
void Awake()
{
Instance = this; // However make sure there is only one object containing this script in the scene all time.
}
void Start()
{
//This gets the Animator, which should be attached to the GameObject you are intending to animate.
m_Animator = gameObject.GetComponent<Animator>();
Loading = false;
}
public void Show()
{
Loading = true;
m_Animator.SetBool("Loading", Loading); // this will show the panel.
}
public void Hide()
{
Loading = false;
m_Animator.SetBool("Loading", Loading); // this will hide the panel.
}
}
そして、UIを操作する任意のスクリプトで:
public void BuyButtonClicked()
{
Loader.Instance.Show();
// process time taking stuff
Loader.Instance.Hide();
}
また、(例えば回転ユニティ内で簡単な画像やアニメーションツールを使用して、パネルオブジェクトの子としてロードアニメーションの任意の種類を作成することができますアニメーション(fidgetスピナー、そのクールを使用))。
そして、ユーザーはあなたがどんなロードを例に従うことによって進行中であるかどうかをチェックすることによって戻って防ぐことができ、ボタンをOSに戻って押して、画面を終了するためのオプションを持っているのAndroidの場合:
// code for back button
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
BackButtonPressed();
}
}
void BackButtonPressed()
{
if(Loader.Instance.Loading)
return;
// use back button event. (For example to leave screen)
}
・ホープ、このことができます。)
購入前と購入後の呼び出しでは、ローダーを非表示にして別の方法を表示することはできません。そうしないと、IEnumeratorではないためすべてのことが起こります。 – Siddharth
明らかにあなたはそれをするべきではありません。そのメソッドを呼び出す場所のアイデアを伝えるだけの例です。コルーチン内部で両方のメソッドを呼び出すことができます –
@Siddharthは答えを受け入れてください –