mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-03-26 20:34:59 -05:00
FindObjectsBy系のAPIは、UniVRMがサポートしているUnityのうち、次の範囲のバージョンには存在しない。 - 2021.3.0~2021.3.17 - 2022.1.0~2022.1.24 - 2022.2.0~2022.2.4 そのため、該当するバージョンのUnityではコンパイルエラーが発生していた。UNITY_2022_3_OR_NEWERで分岐することで、旧APIと新APIを安全に選択するようにした。 厳密にはUNITY_2022_2_5_OR_NEWERを用いたいが、そのようなシンボルは存在していなかった。
28 lines
870 B
C#
28 lines
870 B
C#
using System.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
namespace VRM.FirstPersonSample
|
|
{
|
|
public class CanvasManager : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
public Button LoadVRMButton;
|
|
|
|
[SerializeField]
|
|
public Button LoadBVHButton;
|
|
|
|
private void Reset()
|
|
{
|
|
#if UNITY_2022_3_OR_NEWER
|
|
LoadVRMButton = GameObject.FindObjectsByType<Button>(FindObjectsSortMode.InstanceID).FirstOrDefault(x => x.name == "LoadVRM");
|
|
LoadBVHButton = GameObject.FindObjectsByType<Button>(FindObjectsSortMode.InstanceID).FirstOrDefault(x => x.name == "LoadBVH");
|
|
#else
|
|
LoadVRMButton = GameObject.FindObjectsOfType<Button>().FirstOrDefault(x => x.name == "LoadVRM");
|
|
LoadBVHButton = GameObject.FindObjectsOfType<Button>().FirstOrDefault(x => x.name == "LoadBVH");
|
|
#endif
|
|
}
|
|
}
|
|
}
|