Add option to disable camera

This commit is contained in:
in0finite 2019-05-22 22:43:15 +02:00
parent cdf12168c5
commit 47c7c5a694
2 changed files with 15 additions and 1 deletions

View file

@ -69,12 +69,18 @@ namespace SanAndreasUnity.Settings {
persistType = OptionsWindow.InputPersistType.OnStart
};
OptionsWindow.BoolInput m_enableCamera = new OptionsWindow.BoolInput ("Enable camera") {
getValue = () => Camera.main != null && Camera.main.enabled,
setValue = (value) => { Camera cam = F.FindMainCameraEvenIfDisabled(); if (cam != null) cam.enabled = value; },
persistType = OptionsWindow.InputPersistType.None,
};
void Awake ()
{
var inputs = new OptionsWindow.Input[] { m_timeScaleInput, m_gravityInput, m_displayHealthBarsInput, m_displayMinimapInput,
m_runInBackgroundInput, m_drawLineFromGunInput,
m_runInBackgroundInput, m_drawLineFromGunInput, m_enableCamera,
m_syncVehiclesLinearVelocity, m_syncVehiclesAngularVelocity, m_disableVehiclesRigidBodyOnClients,
m_syncPedTransformWhileInVehicle,
};

View file

@ -723,6 +723,14 @@ namespace SanAndreasUnity.Utilities
return cam.ViewportPointToRay (viewportPos);
}
public static Camera FindMainCameraEvenIfDisabled()
{
GameObject camObj = GameObject.FindGameObjectWithTag("MainCamera");
if (camObj != null)
return camObj.GetComponentInChildren<Camera>(true);
return null;
}
public static void GizmosDrawLineFromCamera ()
{