UI内でobjectのONOFFをしたらエラー文がでる

194 views
Skip to first unread message

億千

unread,
Feb 11, 2021, 1:20:30 AM2/11/21
to 宴ユーザーグループ
Unity と 宴 最新です
win10
Unity歴 3年です

 お世話になっております
 UIでobjectのONOFFを使用すると以下の文が出るようになりました。お手数ですがお暇な時でもご教授頂けると幸いです

 エラー文
NullReferenceException: Object reference not set to an instance of an object
Utage.AdvParamManager.GetParameter[T] (System.String key) (at Assets/Utage/Scripts/ADV/DataManager/SettingData/Param/AdvParamManager.cs:192)
Utage.AdvParamManager.GetParameterInt (System.String key) (at Assets/Utage/Scripts/ADV/DataManager/SettingData/Param/AdvParamManager.cs:152)
objectOC.Update () (at Assets/gadanti/Scripts/objectOC.cs:22)


 スクリプト
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Utage;

public class objectOC : MonoBehaviour
{
    public AdvEngine engine;
    [Header("開きたいゲームオブジェクト")]
    public GameObject Object;
    
    // Start is called before the first frame update
    void Start()
    {
        Object.SetActive(false);
    }

    // Update is called once per frame
    void Update()
    { // 宴変数呼び出し
        int param = (int)engine.Param.GetParameterInt("Fkamera");

        //objectのONOFF
        if (param > 0)
        {
            Object.SetActive(false);
        }

        else
        {
            Object.SetActive(true);
        }

    }
}


マッドネスラボ

unread,
Feb 11, 2021, 1:56:36 AM2/11/21
to 宴ユーザーグループ
宴の起動処理が終わっていない状態で呼び出すとそのようになります。

起動が終わったかは、engine.IsWaitBootLoadingでチェックできるので

呼び出し前に
if(!engine.IsWaitBootLoading) return;
などとして、チェック処理を入れてください。



2021年2月11日木曜日 15:20:30 UTC+9 億千:

億千

unread,
Feb 11, 2021, 4:54:31 AM2/11/21
to 宴ユーザーグループ
申し訳ないですが、私の知識ではおっしゃる意味がわかりません。
もう少し簡単に教えていただけると嬉しいです。すみません

2021年2月11日木曜日 15:56:36 UTC+9 マッドネスラボ:

マッドネスラボ

unread,
Feb 11, 2021, 6:05:21 AM2/11/21
to 宴ユーザーグループ
サンプルを書きました。

engine.IsWaitBootLoadingよりも、engine.Param.IsInitを使うほうが良いのでそのサンプルを書いておきました。


2021年2月11日木曜日 18:54:31 UTC+9 億千:

億千

unread,
Feb 12, 2021, 3:09:14 AM2/12/21
to 宴ユーザーグループ
お忙しい中ありがとうございます。
できるようになりました

2021年2月11日木曜日 20:05:21 UTC+9 マッドネスラボ:
Reply all
Reply to author
Forward
0 new messages