?如上图,做编辑器工具时需要代码切换到Cardboard XR plugin, 代码片段如下,拿去用不谢
XRGeneralSettings androidXRSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Android);
if (androidXRSettings == null)
{
var assignedSettings = ScriptableObject.CreateInstance<XRManagerSettings>() as XRManagerSettings;
androidXRSettings.AssignedSettings = assignedSettings;
EditorUtility.SetDirty(androidXRSettings); // Make sure this gets picked up for serialization later.
}
//取消当前选择的
IReadOnlyList<XRLoader> list = androidXRSettings.Manager.activeLoaders;
int hasCount = list.Count;
//Debug.Log(hasCount);
for (int i = 0; i < hasCount; i++)
{
string nameTemp = list[0].GetType().FullName;
Debug.Log("disable xr plug:" + nameTemp);
XRPackageMetadataStore.RemoveLoader(androidXRSettings.Manager, nameTemp, BuildTargetGroup.Android);
}
//启用
string loaderTypeName = "Google.XR.Cardboard.XRLoader";
XRPackageMetadataStore.AssignLoader(androidXRSettings.Manager, loaderTypeName, BuildTargetGroup.Android);
|