// Use this for initialization void Awake() { Shader.SetGlobalFloat("_LightingFactor", GameSettings.Instance.AllowDeferredShading ? _characterLighting : _characterLighting + 0.2f); Shader.SetGlobalColor("_spotLightColor", _spotLightColor); Shader.SetGlobalColor("_sceneReflectionColor", _reflectionColor); s_completeCamera = _completeCamera; }
public void SetFeatureCamera(FCCamera camera, float duration, GameObject target, string CALLBACK) { _oldCamera = _currentCamera; _currentCamera = camera; _duration = duration; _timer = 0.0f; _callbackTarget = target; _callbackname = CALLBACK; }
public void SetCurrentCamera(CameraMode mode) { FCCamera fcamera = _cameraModes [(int)mode]; SetCurrentCamera(fcamera); if (mode == CameraMode.PushingBox) { SetTarget2(null); } }
public void SetTarget(Transform target) { _target = target; if (target != null) { _previousTargetPos = target.position; } FCCamera ewcam = (_currentCamera != null ? _currentCamera : _cameraModes [0]); //ewcam.OnSetTarget(target, ref _target2); ewcam.UpdatePosAndRotation(target, _target2, false, ref _previousPos, ref _previousTargetPos); LevelLightInfo.s_completeCamera = null; }
void OnDestroy() { s_completeCamera = null; }
void SetCurrentCamera(FCCamera fcamera) { _currentCamera = fcamera; }
void UpdateInternal(float deltaTime) { #if UNITY_EDITOR _coreCamera.backgroundColor = RenderSettings.fogColor; #endif Vector3 pos = _previousPos; Vector3 focus = _previousTargetPos; float fov = _currentCamera.fieldOfView + _currentCamera.fovFactorOnPhone * _fovFactor; Vector2 clipPlane = _currentCamera.clipPlanes; if (_oldCamera != null) { _currentCamera.UpdatePosAndRotation(_target, _target2, true, ref pos, ref focus); _timer += deltaTime; float percent = Mathf.Min(_timer / _duration, 1.0f); Vector3 pos2 = _previousPos; Vector3 focus2 = _previousTargetPos; _oldCamera.UpdatePosAndRotation(_target, _target2, false, ref pos2, ref focus2); pos = Vector3.Lerp(pos2, pos, percent); focus = Vector3.Lerp(focus2, focus, percent); fov = Mathf.Lerp(_oldCamera.fieldOfView + _oldCamera.fovFactorOnPhone * _fovFactor, fov, percent); clipPlane = Vector2.Lerp(_oldCamera.clipPlanes, clipPlane, percent); if (percent >= 1.0f) { _oldCamera = null; if (_callbackTarget != null) { _callbackTarget.SendMessage(_callbackname); } } } else { _currentCamera.UpdatePosAndRotation(_target, _target2, true, ref pos, ref focus); } if (_skillCamera != null) { _skillTime += deltaTime; _skillCamera.Update(_skillTime, _skillCameraCache); if (_skillTime >= _skillCamera.duration && !_forceHold) { _skillCamera = null; _shakeCamera.StopShake(); } } else { _skillCameraCache.SetParameter(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); } _previousPos = pos; _previousTargetPos = focus; Vector3 originPos = pos - focus; Vector3 normalizeOriginPos = originPos.normalized; originPos += normalizeOriginPos * _skillCameraCache.distance; Vector3 virPos = Vector3.Cross(Vector3.left, Vector3.forward).normalized; originPos += virPos * _skillCameraCache.vertical; if (0 != _skillCameraCache.vertical) { Debug.Log(string.Format("originPos = {0}", originPos)); } Vector3 horiPos = Vector3.Cross(Vector3.up, Vector3.forward).normalized; originPos += horiPos * _skillCameraCache.horizontal; Quaternion rot = Quaternion.AngleAxis(_skillCameraCache.verticalRotation, Vector3.Cross(Vector3.up, normalizeOriginPos)); originPos = rot * originPos; rot = Quaternion.AngleAxis(_skillCameraCache.horizontalRotation, Vector3.up); originPos = rot * originPos; pos = originPos + focus; _transform.position = pos; _transform.LookAt(focus); _coreCamera.fieldOfView = fov + _skillCameraCache.fieldOfView; _coreCamera.nearClipPlane = clipPlane.x; _coreCamera.farClipPlane = clipPlane.y; // shadow camera update. if (_shadowCameraTransform != null) { _shadowCameraTransform.position = focus; } }
// Use this for initialization void Start() { _transform = transform; _effectAnimation = gameObject.transform.FindChild("CameraEffects").gameObject.GetComponent <Animation>(); string cameraPath = _forwardCameraPath; if (GameSettings.Instance.IsDeferredShadingActived()) { cameraPath = _deferredCameraPath; } GameObject camObj = InJoy.AssetBundles.AssetBundles.Load(cameraPath, typeof(GameObject)) as GameObject; camObj = GameObject.Instantiate(camObj) as GameObject; camObj.transform.parent = _cameraParent; camObj.transform.localPosition = Vector3.zero; camObj.transform.localRotation = Quaternion.identity; camObj.transform.localScale = Vector3.one; _coreCamera = camObj.gameObject.GetComponent <Camera>(); _timer = 0.0f; _duration = 1000.0f; _fovFactor = GameSettings.Instance.FovFactor; _shakeCamera = new ShakeCamera(); _shakeCamera.SetAnim(_effectAnimation, _effectAnimation.clip.name); if (_currentCamera == null) { Assertion.Check(_cameraModes.Length > 0); SetCurrentCamera(CameraMode.Standard); } _oldCamera = null; _coreCamera.backgroundColor = RenderSettings.fogColor; LevelLightInfo level = GameObject.FindObjectOfType(typeof(LevelLightInfo)) as LevelLightInfo; Renderer [] sceneRenderers = new Renderer[0]; if (level != null) { sceneRenderers = level.GetComponentsInChildren <Renderer>(); } if (!GameSettings.Instance.IsFullSceneDisplay()) { int layer = LayerMask.NameToLayer("NONE"); foreach (Renderer r in sceneRenderers) { string shaderName = r.sharedMaterial.shader.name; if (shaderName.Contains("(noshadow)")) { r.gameObject.layer = layer; } } } if (GameSettings.Instance.IsDirectionalShadowActived()) { _shadowRT = RenderTexture.GetTemporary(800, 800, 0, RenderTextureFormat.ARGB32); GameObject cameraObj = GameObject.Instantiate(_shadowCamera) as GameObject; _shadowCameraInstance = cameraObj.GetComponentInChildren <Camera>(); if (_shadowCameraInstance != null) { _shadowCameraInstance.targetTexture = _shadowRT; _shadowCameraInstance.enabled = false; _shadowCameraInstance.SetReplacementShader(_shadowShader, ""); _shadowCameraInstance.Render(); _shadowCameraInstance.aspect = 1.0f; foreach (Renderer r in sceneRenderers) { if (null != r && null != r.sharedMaterial) { r.sharedMaterial.SetTexture("_shadowTex", _shadowRT); } } } _shadowCameraTransform = cameraObj.GetComponent <Transform>(); _shadowRenderer = _shadowCameraInstance.GetComponentInChildren <ShadowRenderer>(); GameObject mainLight = GameObject.FindWithTag("MainLight"); if (mainLight != null && _shadowRenderer != null) { _shadowRenderer.SetDirectionalLight(mainLight.transform); } Shader.SetGlobalTexture("_shadowBorder", _shadowBorder); } }