static public void SyncCameraParameters(Camera src, Camera dst) { if (dst == null) { return; } if (src.clearFlags == CameraClearFlags.Skybox) { Skybox sky = src.GetComponent(typeof(Skybox)) as Skybox; Skybox mysky = dst.GetComponent(typeof(Skybox)) as Skybox; if (!sky || !sky.material) { mysky.enabled = false; } else { mysky.enabled = true; mysky.material = sky.material; } } dst.clearFlags = src.clearFlags; dst.backgroundColor = src.backgroundColor; dst.farClipPlane = src.farClipPlane; dst.nearClipPlane = src.nearClipPlane; dst.orthographic = src.orthographic; dst.fieldOfView = src.fieldOfView; dst.aspect = src.aspect; dst.orthographicSize = src.orthographicSize; }
void UpdateCameraModes(Camera src, Camera dest) { // set water camera to clear the same way as current camera dest.renderingPath = _forceForwardRenderingPath ? RenderingPath.Forward : src.renderingPath; dest.backgroundColor = new Color(0f, 0f, 0f, 0f); dest.clearFlags = _clearFlags; if (_clearFlags == CameraClearFlags.Skybox) { Skybox sky = src.GetComponent <Skybox>(); Skybox mysky = dest.GetComponent <Skybox>(); if (!sky || !sky.material) { mysky.enabled = false; } else { mysky.enabled = true; mysky.material = sky.material; } } // update other values to match current camera. // even if we are supplying custom camera&projection matrices, // some of values are used elsewhere (e.g. skybox uses far plane) dest.farClipPlane = src.farClipPlane; dest.nearClipPlane = src.nearClipPlane; dest.orthographic = src.orthographic; dest.fieldOfView = src.fieldOfView; dest.orthographicSize = src.orthographicSize; dest.allowMSAA = _allowMSAA; dest.aspect = src.aspect; }
private void UpdateCameraModes(Camera src, Camera dest) { if (dest == null) { return; } dest.clearFlags = src.clearFlags; dest.backgroundColor = src.backgroundColor; if (src.clearFlags == CameraClearFlags.Skybox) { Skybox srcSkyBox = src.GetComponent <Skybox>(); Skybox destSkybox = dest.GetComponent <Skybox>(); if (!srcSkyBox || !srcSkyBox.material) { destSkybox.enabled = false; } else { destSkybox.enabled = true; destSkybox.material = srcSkyBox.material; } } dest.farClipPlane = src.farClipPlane; dest.nearClipPlane = src.nearClipPlane; dest.orthographic = src.orthographic; dest.fieldOfView = src.fieldOfView; dest.aspect = src.aspect; dest.orthographicSize = src.orthographicSize; dest.renderingPath = src.renderingPath; }
void EnsureEyeCamera(Camera mainCamera, String eyeCameraName, Rect rect, ref Camera eyeCamera) { // Creates eye camera object if it doesn't exist. if (eyeCamera == null) { var eyeCameraObject = new GameObject(mainCamera.gameObject.name + eyeCameraName); eyeCamera = eyeCameraObject.AddComponent <Camera>(); eyeCameraObject.transform.SetParent(mainCamera.gameObject.transform, false); } eyeCamera.CopyFrom(mainCamera); eyeCamera.rect = rect; eyeCamera.targetTexture = renderTexture; // Match child camera's skyboxes to main camera. Skybox monoCameraSkybox = mainCamera.gameObject.GetComponent <Skybox>(); Skybox customSkybox = eyeCamera.GetComponent <Skybox>(); if (monoCameraSkybox != null) { if (customSkybox == null) { customSkybox = eyeCamera.gameObject.AddComponent <Skybox>(); } customSkybox.material = monoCameraSkybox.material; } else if (customSkybox != null) { Destroy(customSkybox); } }
// Start is called before the first frame update void Start() { blur = view.GetComponent <SuperBlur.SuperBlur>(); sky = view.GetComponent <Skybox>(); transitioningStart = false; transitionLogic = DataCollection.ME.GetComponent <TransitionLogic>(); }
protected override void ReadFromImpl(object obj) { base.ReadFromImpl(obj); Skybox uo = (Skybox)obj; material = ToID(uo.material); }
private void UpdateCameraModes(Camera src, Camera dest) { if (dest != null) { dest.clearFlags = src.clearFlags; dest.backgroundColor = src.backgroundColor; if (src.clearFlags == CameraClearFlags.Skybox) { Skybox component = src.GetComponent <Skybox>(); Skybox skybox2 = dest.GetComponent <Skybox>(); if (!component || !component.material) { skybox2.enabled = false; } else { skybox2.enabled = true; skybox2.material = component.material; } } dest.farClipPlane = src.farClipPlane; dest.nearClipPlane = src.nearClipPlane; dest.orthographic = src.orthographic; dest.fieldOfView = src.fieldOfView; dest.aspect = src.aspect; dest.orthographicSize = src.orthographicSize; } }
// Use this for initialization void Start() { //Download all of the appropriate textures Texture2D[] textures = getTexturesFromURL("http://maps.googleapis.com/maps/api/streetview", 48.8577569, 2.2953444, imgWidth, imgHeight); //lat, long, width, height //debug length Debug.Log("texture length:" + textures.Length); //Grab both of the cameras for each lens on the Oculus GameObject[] cams = { GameObject.FindWithTag("LeftCam"), GameObject.FindWithTag("RightCam") }; //Map each texture to the correct location on the SkyBox foreach (GameObject cam in cams) { Skybox skyBox = cam.GetComponent <Skybox> (); Material material = skyBox.material; // Box is inverted along y axis (Rotating counter-clockwise) material.SetTexture("_LeftTex", textures [0]); material.SetTexture("_BackTex", textures [1]); material.SetTexture("_RightTex", textures [2]); material.SetTexture("_FrontTex", textures [3]); material.SetTexture("_UpTex", textures [4]); material.SetTexture("_DownTex", textures [5]); //debug length Debug.Log("texture length:" + textures.Length); } }
/// <summary> /// Update the reflection cameras sky box to /// match the current cameras sky box. /// </summary> void UpdateSkyBox(Camera cam, Camera reflectCamera) { //NOT USED reflectCamera.backgroundColor = m_ocean.defaultSkyColor; reflectCamera.clearFlags = CameraClearFlags.SolidColor; if (skyboxInReflection && cam.clearFlags == CameraClearFlags.Skybox) { reflectCamera.clearFlags = CameraClearFlags.Skybox; Skybox skybox = cam.gameObject.GetComponent <Skybox>(); if (skybox) { Skybox sb = reflectCamera.gameObject.GetComponent <Skybox>(); if (!sb) { sb = reflectCamera.gameObject.AddComponent <Skybox>(); } sb.material = skybox.material; } } }
/// <summary> /// On ajoute la skybox à toutes les caméras /// </summary> /// <param name="sk"></param> public void AddSkybox(Skybox sk) { foreach (Camera cam in Cameras) { cam.Skybox = new Skybox(cam.Entity); } }
private void UpdateCameraModes(Camera src, Camera dest) { if (Object.op_Equality((Object)dest, (Object)null)) { return; } dest.set_clearFlags(src.get_clearFlags()); dest.set_backgroundColor(src.get_backgroundColor()); if (src.get_clearFlags() == 1) { Skybox component1 = ((Component)src).GetComponent(typeof(Skybox)) as Skybox; Skybox component2 = ((Component)dest).GetComponent(typeof(Skybox)) as Skybox; if (!Object.op_Implicit((Object)component1) || !Object.op_Implicit((Object)component1.get_material())) { ((Behaviour)component2).set_enabled(false); } else { ((Behaviour)component2).set_enabled(true); component2.set_material(component1.get_material()); } } dest.set_farClipPlane(src.get_farClipPlane()); dest.set_nearClipPlane(src.get_nearClipPlane()); dest.set_orthographic(src.get_orthographic()); dest.set_fieldOfView(src.get_fieldOfView()); dest.set_aspect(src.get_aspect()); dest.set_orthographicSize(src.get_orthographicSize()); }
private void UpdateCameraModes(Camera src, Camera dest) { if (dest == null) { return; } // set water camera to clear the same way as current camera dest.clearFlags = src.clearFlags; dest.backgroundColor = src.backgroundColor; if (src.clearFlags == CameraClearFlags.Skybox) { Skybox sky = src.GetComponent(typeof(Skybox)) as Skybox; Skybox mysky = dest.GetComponent(typeof(Skybox)) as Skybox; if (!sky || !sky.material) { mysky.enabled = false; } else { mysky.enabled = true; mysky.material = sky.material; } } // update other values to match current camera. // even if we are supplying custom camera&projection matrices, // some of values are used elsewhere (e.g. skybox uses far plane) dest.farClipPlane = src.farClipPlane; dest.nearClipPlane = src.nearClipPlane; dest.orthographic = src.orthographic; dest.fieldOfView = src.fieldOfView; dest.aspect = src.aspect; dest.orthographicSize = src.orthographicSize; }
protected override void Start() { _sunShadows = GameObject.Find("light_shadows").GetComponent<Light>(); _sunContrast = GameObject.Find("light_contrast").GetComponent<Light>(); GameObject go = GameObject.Find("particles"); if (go != null) _particles = go.GetComponent<ParticleSystem>(); _skybox = Player.instance.vertical.GetComponentInChildren<Skybox>(); //_ssao = Camera.main.GetComponent<SSAOPro>(); _propsShadows = GameObject.Find("light_props_shadows").GetComponent<Light>(); _propsContrast = GameObject.Find("light_props_contrast").GetComponent<Light>(); #if UNITY_EDITOR if (_sunShadows == null) GameConsole.instance.writeNewMessage("[" + GetType() + "] " + name + " : there is no light_shadows in the current scene !", GameConsole.AlertStates.warning); if (_sunContrast == null) GameConsole.instance.writeNewMessage("[" + GetType() + "] " + name + " : there is no light_contrast in the current scene !", GameConsole.AlertStates.warning); if (go == null) GameConsole.instance.writeNewMessage("[" + GetType() + "] " + name + " : there is no particles in the current scene !", GameConsole.AlertStates.warning); if (_skybox == null) GameConsole.instance.writeNewMessage("[" + GetType() + "] " + name + " : there is no particles in the current scene !", GameConsole.AlertStates.warning); //if (_ssao == null) GameConsole.instance.writeNewMessage("[" + GetType() + "] " + name + " : there is no SSAO script on main camera !", GameConsole.AlertStates.warning); if (_propsShadows == null) GameConsole.instance.writeNewMessage("[" + GetType() + "] " + name + " : there is no light_props_shadows in the current scene !", GameConsole.AlertStates.warning); if (_propsContrast == null) GameConsole.instance.writeNewMessage("[" + GetType() + "] " + name + " : there is no light_props_contrast in the current scene !", GameConsole.AlertStates.warning); #endif base.Start(); }
private void SyncCameraSettings(Camera reflectCamera, Camera sourceCamera) { reflectCamera.nearClipPlane = (NearPlane <= 0.0f ? sourceCamera.nearClipPlane : NearPlane); reflectCamera.farClipPlane = (FarPlane <= 0.0f ? sourceCamera.farClipPlane : FarPlane); reflectCamera.aspect = (AspectRatio <= 0.0f ? sourceCamera.aspect : AspectRatio); if (!reflectCamera.stereoEnabled) { reflectCamera.fieldOfView = (FieldOfView <= 0.0f ? sourceCamera.fieldOfView : FieldOfView); } reflectCamera.orthographic = sourceCamera.orthographic; reflectCamera.orthographicSize = sourceCamera.orthographicSize; reflectCamera.renderingPath = (ReflectionCameraRenderingPath == RenderingPath.UsePlayerSettings ? sourceCamera.renderingPath : ReflectionCameraRenderingPath); reflectCamera.backgroundColor = Color.red; reflectCamera.clearFlags = ReflectSkybox ? CameraClearFlags.Skybox : CameraClearFlags.SolidColor; reflectCamera.cullingMask = ReflectionMask; reflectCamera.stereoSeparation = sourceCamera.stereoSeparation; reflectCamera.rect = new Rect(0.0f, 0.0f, 1.0f, 1.0f); //reflectCamera.transform.rotation = sourceCamera.transform.rotation; //reflectCamera.transform.position = sourceCamera.transform.position; if (ReflectSkybox) { if (sourceCamera.gameObject.GetComponent(typeof(Skybox))) { Skybox sb = (Skybox)reflectCamera.gameObject.GetComponent(typeof(Skybox)); if (!sb) { sb = (Skybox)reflectCamera.gameObject.AddComponent(typeof(Skybox)); sb.hideFlags = HideFlags.HideAndDontSave; } sb.material = ((Skybox)sourceCamera.GetComponent(typeof(Skybox))).material; } } }
/// <summary> /// Copy camera settings from source to destination. /// </summary> void CopyCamera(Camera src, Camera dest) { if (src.clearFlags == CameraClearFlags.Skybox) { Skybox sky = src.GetComponent <Skybox>(); Skybox mysky = dest.GetComponent <Skybox>(); if (!sky || !sky.material) { mysky.enabled = false; } else { mysky.enabled = true; mysky.material = sky.material; } } dest.clearFlags = src.clearFlags; dest.backgroundColor = src.backgroundColor; dest.farClipPlane = src.farClipPlane; dest.nearClipPlane = src.nearClipPlane; dest.orthographic = src.orthographic; dest.fieldOfView = src.fieldOfView; dest.aspect = src.aspect; dest.orthographicSize = src.orthographicSize; dest.depthTextureMode = DepthTextureMode.None; dest.renderingPath = RenderingPath.Forward; }
// Token: 0x06001841 RID: 6209 RVA: 0x000D9D98 File Offset: 0x000D7F98 private void UpdateCameraModes(Camera src, Camera dest) { if (dest == null) { return; } dest.clearFlags = src.clearFlags; dest.backgroundColor = src.backgroundColor; if (src.clearFlags == CameraClearFlags.Skybox) { Skybox skybox = src.GetComponent(typeof(Skybox)) as Skybox; Skybox skybox2 = dest.GetComponent(typeof(Skybox)) as Skybox; if (!skybox || !skybox.material) { skybox2.enabled = false; } else { skybox2.enabled = true; skybox2.material = skybox.material; } } dest.farClipPlane = src.farClipPlane; dest.nearClipPlane = src.nearClipPlane; dest.orthographic = src.orthographic; dest.fieldOfView = src.fieldOfView; dest.aspect = src.aspect; dest.orthographicSize = src.orthographicSize; }
void Start() { sky = GetComponent <Skybox> (); nowTime = 0; sky.material = skybox [0]; InvokeRepeating("Change", ChangePeriod, ChangePeriod); }
protected override void AddLightInternal(LightComponent light) { // TODO: If there is a performance penalty for accessing the SkyboxComponent, this could be prepared by the LightProcessor var lightSkybox = ((LightSkybox)light.Type); var skyboxComponent = lightSkybox.SkyboxComponent; var skybox = skyboxComponent.Skybox; intensity = light.Intensity; if (skyboxComponent.Enabled) { intensity *= skyboxComponent.Intensity; } rotationMatrix = lightSkybox.SkyMatrix; var diffuseParameters = skybox.DiffuseLightingParameters; var specularParameters = skybox.SpecularLightingParameters; specularCubemap = specularParameters.Get(SkyboxKeys.CubeMap); if (specularCubemap != null) { specularCubemapLevels = specularCubemap.MipLevels; } sphericalColors = diffuseParameters.GetValues(SphericalHarmonicsEnvironmentColorKeys.SphericalColors); lightDiffuseColorShader = diffuseParameters.Get(SkyboxKeys.Shader) ?? EmptyComputeEnvironmentColorSource; lightSpecularColorShader = specularParameters.Get(SkyboxKeys.Shader) ?? EmptyComputeEnvironmentColorSource; previousSkybox = skybox; }
public void ApplySkyboxParams() { if (Skyboxbg != null) { if (Skyboxbg.HasProperty(_Exposure)) { Skyboxbg.SetFloat(_Exposure, skyboxParams.exposure); } if (Skyboxbg.HasProperty(_Rotation)) { Skyboxbg.SetFloat(_Rotation, skyboxParams.rotation); } if (Skyboxbg.HasProperty(_Tint)) { Skyboxbg.SetColor(_Tint, skyboxParams.tint); } } if (Skybox != null) { if (Skybox.HasProperty(_Exposure)) { Skybox.SetFloat(_Exposure, skyboxParams.exposure); } if (Skybox.HasProperty(_Tint)) { Skybox.SetColor(_Tint, skyboxParams.tint); } if (Skybox.HasProperty(_Rotation)) { Skybox.SetFloat(_Rotation, skyboxParams.rotation); } } }
void UpdateCameraModes(Camera src, Camera dest) { if (dest == null) { return; } dest.clearFlags = src.clearFlags; dest.backgroundColor = src.backgroundColor; if (src.clearFlags == CameraClearFlags.Skybox) { Skybox sky = src.GetComponent <Skybox>(); Skybox mysky = dest.GetComponent <Skybox>(); if (!sky || !sky.material) { mysky.enabled = false; } else { mysky.enabled = true; mysky.material = sky.material; } } dest.farClipPlane = src.farClipPlane; dest.nearClipPlane = src.nearClipPlane; dest.orthographic = src.orthographic; dest.fieldOfView = src.fieldOfView; dest.aspect = src.aspect; dest.orthographicSize = src.orthographicSize; }
/// <summary> /// Loads the content. /// </summary> /// <param name="content">The ContentManager.</param> public override void LoadContent(ContentManager content) { _skyBox = new Skybox(new[] { content.Load <Texture2D>("mainbackground.png"), content.Load <Texture2D>("bgLayer1.png"), content.Load <Texture2D>("bgLayer2.png") }); _header = new Font("Segoe UI", 25, TypefaceStyle.Bold); _subHeader = new Font("Segoe UI", 40, TypefaceStyle.Bold); _fadeableText1 = new FadeableText { Font = _header, Text = "ThuCommix presents", Position = new Vector2(270, 200), FadeInVelocity = 2, FadeOutVelocity = 3 }; _fadeableText2 = new FadeableText { Font = _header, Text = "a game powered by Sharpex2D", Position = new Vector2(220, 200), FadeInVelocity = 2, FadeOutVelocity = 3 }; _fadeableText3 = new FadeableText { Font = _subHeader, Text = "XPlane", Position = new Vector2(330, 200), FadeInVelocity = 2, FadeOutVelocity = 2 }; }
protected override void GetDepsFromImpl(object obj, GetDepsFromContext context) { base.GetDepsFromImpl(obj, context); Skybox uo = (Skybox)obj; AddDep(uo.material, context); }
private void UpdateCameraModes(Camera src, Camera dest) { if (dest == null) { return; } dest.set_clearFlags(src.get_clearFlags()); dest.set_backgroundColor(src.get_backgroundColor()); if (src.get_clearFlags() == 1) { Skybox skybox = src.GetComponent(typeof(Skybox)) as Skybox; Skybox skybox2 = dest.GetComponent(typeof(Skybox)) as Skybox; if (!skybox || !skybox.get_material()) { skybox2.set_enabled(false); } else { skybox2.set_enabled(true); skybox2.set_material(skybox.get_material()); } } dest.set_farClipPlane(src.get_farClipPlane()); dest.set_nearClipPlane(src.get_nearClipPlane()); dest.set_orthographic(src.get_orthographic()); dest.set_fieldOfView(src.get_fieldOfView()); dest.set_aspect(src.get_aspect()); dest.set_orthographicSize(src.get_orthographicSize()); }
private void UpdateCameraProperties(Camera src, Camera dest) { dest.clearFlags = src.clearFlags; dest.backgroundColor = src.backgroundColor; if (src.clearFlags == CameraClearFlags.Skybox) { Skybox sky = src.GetComponent <Skybox>(); Skybox mysky = dest.GetComponent <Skybox>(); if (!sky || !sky.material) { mysky.enabled = false; } else { mysky.enabled = true; mysky.material = sky.material; } } dest.orthographic = src.orthographic; dest.orthographicSize = src.orthographicSize; if (mirrorScript.AspectRatio > 0.0f) { dest.aspect = mirrorScript.AspectRatio; } else { dest.aspect = src.aspect; } dest.renderingPath = src.renderingPath; }
private void Start() { if (OceanRenderer.Instance == null) { enabled = false; return; } _camViewpoint = GetComponent <Camera>(); if (!_camViewpoint) { Debug.LogWarning("Disabling planar reflections as no camera found on gameobject to generate reflection from.", this); enabled = false; return; } _camViewpointSkybox = _camViewpoint?.GetComponent <Skybox>(); // This is anyway called in OnPreRender, but was required here as there was a black reflection // for a frame without this earlier setup call. CreateWaterObjects(_camViewpoint); #if UNITY_EDITOR if (!OceanRenderer.Instance.OceanMaterial.IsKeywordEnabled("_PLANARREFLECTIONS_ON")) { Debug.LogWarning("Planar reflections are not enabled on the current ocean material and will not be visible.", this); } #endif }
public TunnelVision() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; input = new InputHandler(this); Components.Add(input); Camera = new TunnelVisionCamera(this); Components.Add(Camera); gameManager = new GameStateManager(this); Components.Add(gameManager); Skybox = new Skybox(this); Components.Add(Skybox); //Components.Add(new GamerServicesComponent(this)); TitleIntroState = new TitleIntroState(this); StartMenuState = new StartMenuState(this); OptionsMenuState = new OptionsMenuState(this); PlayingState = new PlayingState(this); StartLevelState = new StartLevelState(this); FadingState = new FadingState(this); LostGameState = new LostGameState(this); WonGameState = new WonGameState(this); PausedState = new PausedState(this); YesNoDialogState = new YesNoDialogState(this); //HighScoresState = new HighScoresState(this); gameManager.ChangeState(TitleIntroState.Value); }
/// <summary> /// Create a new instance of VGO_Skybox by specifying Skybox and glTF. /// </summary> /// <param name="skybox"></param> /// <param name="gltf"></param> public VGO_Skybox(Skybox skybox, glTF gltf) { if (skybox == null) { return; } if (gltf == null) { return; } if (skybox.material == null) { return; } if (gltf.materials == null) { return; } string skyboxMaterialName = skybox.material.name; for (int index = 0; index < gltf.materials.Count; index++) { if (gltf.materials[index].name == skyboxMaterialName) { materialIndex = index; break; } } }
void Start() { // Construct a rotation matrix and set it for the shader Skybox sb = GetComponent <Skybox>(); switch (Random.Range(0, 4)) { case 0: sb.material = skybox2; break; case 1: sb.material = skybox1; break; case 2: sb.material = skybox2; break; case 3: sb.material = skybox3; break; default: sb.material = skybox1; break; } mt = sb.material; sb.material.SetFloat("Exposure", Random.Range(0.5f, 1.5f)); }
/// <summary> /// Creates a copy of a target camera parented under that camera. /// </summary> static void CreateCopy(Camera TargetCam) { GameObject NewObj = new GameObject(); NewObj.transform.parent = TargetCam.gameObject.transform; NewObj.transform.localPosition = new Vector3(-EyeDistance, 0, 0); NewObj.transform.localEulerAngles = new Vector3(0, EyeRotation, 0); float FovExtension = Screen.width / (float)Screen.height; TargetCam.fieldOfView *= FovExtension; TargetCam.orthographicSize *= FovExtension; TargetCam.rect = new Rect(.5f, 0, .5f, 1); Camera OtherEye = (Camera)CopyComponent(TargetCam, NewObj); OtherEye.rect = new Rect(0, 0, .5f, 1); // Copy skybox Skybox Sky = TargetCam.gameObject.GetComponent <Skybox>(); if (Sky) { CopyComponent(Sky, NewObj); } // Group OtherEyes.Add(OtherEye); if (TargetCam == Camera.main) { OtherMain = OtherEye; } }
private void SetCamera(Camera src, Camera dst) { if (src == null || dst == null) { return; } dst.clearFlags = src.clearFlags; dst.backgroundColor = src.backgroundColor; if (src.clearFlags == CameraClearFlags.Skybox) { Skybox srcSky = src.GetComponent <Skybox>(); Skybox dstSky = dst.GetComponent <Skybox>(); if (srcSky == null || srcSky.material == null) { dstSky.enabled = false; } else { dstSky.enabled = true; dstSky.material = srcSky.material; } } dst.orthographic = src.orthographic; dst.farClipPlane = src.farClipPlane; dst.nearClipPlane = src.nearClipPlane; dst.fieldOfView = src.fieldOfView; dst.aspect = src.aspect; dst.orthographicSize = src.orthographicSize; }
public virtual void OnOverlayGUI(UnityEngine.Object target, SceneView sceneView) { if (!(target == null)) { Camera camera = (Camera)target; Vector2 mainGameViewTargetSize = GameView.GetMainGameViewTargetSize(); if (mainGameViewTargetSize.x < 0f) { mainGameViewTargetSize.x = sceneView.position.width; mainGameViewTargetSize.y = sceneView.position.height; } Rect rect = camera.rect; mainGameViewTargetSize.x *= Mathf.Max(rect.width, 0f); mainGameViewTargetSize.y *= Mathf.Max(rect.height, 0f); if (mainGameViewTargetSize.x > 0f && mainGameViewTargetSize.y > 0f) { float num = mainGameViewTargetSize.x / mainGameViewTargetSize.y; mainGameViewTargetSize.y = 0.2f * sceneView.position.height; mainGameViewTargetSize.x = mainGameViewTargetSize.y * num; if (mainGameViewTargetSize.y > sceneView.position.height * 0.5f) { mainGameViewTargetSize.y = sceneView.position.height * 0.5f; mainGameViewTargetSize.x = mainGameViewTargetSize.y * num; } if (mainGameViewTargetSize.x > sceneView.position.width * 0.5f) { mainGameViewTargetSize.x = sceneView.position.width * 0.5f; mainGameViewTargetSize.y = mainGameViewTargetSize.x / num; } Rect rect2 = GUILayoutUtility.GetRect(mainGameViewTargetSize.x, mainGameViewTargetSize.y); if (Event.current.type == EventType.Repaint) { this.previewCamera.CopyFrom(camera); Skybox component = this.previewCamera.GetComponent <Skybox>(); if (component) { Skybox component2 = camera.GetComponent <Skybox>(); if (component2 && component2.enabled) { component.enabled = true; component.material = component2.material; } else { component.enabled = false; } } RenderTexture previewTextureWithSize = this.GetPreviewTextureWithSize((int)rect2.width, (int)rect2.height); previewTextureWithSize.antiAliasing = QualitySettings.antiAliasing; this.previewCamera.targetTexture = previewTextureWithSize; this.previewCamera.pixelRect = new Rect(0f, 0f, rect2.width, rect2.height); Handles.EmitGUIGeometryForCamera(camera, this.previewCamera); GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear); this.previewCamera.Render(); GL.sRGBWrite = false; Graphics.DrawTexture(rect2, previewTextureWithSize, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, GUI.color, EditorGUIUtility.GUITextureBlit2SRGBMaterial); } } } }
public CameraEntityComponent(Entity referringEntity, Skybox skybox, int cameraMask = 1) : base(referringEntity) { Camera = GameInstance.GetService<SceneRenderer>().CreateCamera(cameraMask); NearClipDistance = 0.1f; FarClipDistance = 1000.0f; FieldOfView = MathHelper.PiOver4; ClearColor = Color.CornflowerBlue; Camera.Skybox = skybox; Camera.IsActive = ReferringEntity.IsActive; }
void Start() { _colors = new List<Color>(); foreach(Color item in _colorList._list) { _colors.Add(item); } _skybox = GetComponent<Skybox>(); _skybox.material.SetColor("_Tint", _colors[0]); }
public override void Initialize() { Camera = new Camera((AsteroidDestroyer)game, new Vector3(0, 3, 10), 5f); skybox = new Skybox(game, Resources.Instance.GetModel("skybox"), Resources.Instance.GetTexture("stars"), this); game.Components.Add(skybox); spawner = new AsteroidSpawner((int)Resources.Instance.GameSize, (int)Resources.Instance.GameCount); modelLookup = new Dictionary<int, MobileMeshModel>(); base.Initialize(); }
public GooSkybox(Skybox pSkybox) { _skybox = pSkybox; _top = GetSkyboxSide("_UpTex"); _bottom = GetSkyboxSide("_DownTex"); _left = GetSkyboxSide("_LeftTex"); _right = GetSkyboxSide("_RightTex"); _front = GetSkyboxSide("_FrontTex"); _back = GetSkyboxSide("_BackTex"); AllSkyboxes.Add(this); }
void Start() { sky = GetComponent<Skybox> (); }
void Awake() { unitFoV = OVRDevice.VerticalFOV(); targetOVRCamera = null; skybox = sightOVRCamera.GetComponent<Skybox>(); maxMagnificationRatio = minMagnificationRatio > maxMagnificationRatio ? minMagnificationRatio : maxMagnificationRatio; }
protected override void Initialize() { consoleHUD = new ConsoleHUD(); spriteBatch = new SpriteBatch( graphics.GraphicsDevice ); renderTarget = new RenderTarget2D( graphics.GraphicsDevice, 800, 600, 1, SurfaceFormat.Color ); refractionRenderTarg = new RenderTarget2D( graphics.GraphicsDevice, 800, 600, 1, SurfaceFormat.Color ); reflectionRenderTarg = new RenderTarget2D( graphics.GraphicsDevice, 800, 600, 1, SurfaceFormat.Color ); camera = new MouseCam(); camera.SetPosition( new Vector3( 1500f, 400f, 1500f ) ); camera.rotation = new Vector3( 0f, MathHelper.ToRadians( 180f ), 0f ); //grid = new Grid(new Vector2(1000f, 1000f), 10, Color.Black, 1f, Vector3.Zero, new Vector3(0f, 0f, 0f)); //water = new Water(new Vector2(40000f, 40000f), false); skybox = new Skybox(); sun = new Sun( 342f, 335f ); hud = new HUD(); InitFog(); base.Initialize(); settings = new HeightmapSettings(); settings.Show(); }
/// <summary> /// Deklarerer komponentene /// </summary> protected override void Initialize() { camera = new Camera(this); this.Components.Add(camera); skybox = new Skybox(this, this.Content, camera); this.Components.Add(skybox); terrain = new Terrain(this, this.Content, camera); this.Components.Add(terrain); blimps = new Blimps(this, this.Content, camera, terrain); this.Components.Add(blimps); game = new Plane(this, this.Content, camera); this.Components.Add(game); explo = new ParticleComponent(this, this.Content, camera); this.Components.Add(explo); sprites = new _2Dsprites(this, this.Content, camera); this.Components.Add(sprites); spriteBatch = new SpriteBatch(graphics.GraphicsDevice); base.Initialize(); }
public override void Initialize() { float aspectRatio = game.GraphicsDevice.Viewport.AspectRatio; #region Load Models //Load Models Vector3 initPlayerPosition = new Vector3(0, 0, 0); player = new Player(game, initPlayerPosition, 5f); moon = new Planet(game, new Vector3(0, 0, 9000), 300f, "moon"); game.Components.Add(player); game.Components.Add(moon); #endregion #region Load Cameras //Load Cameras thirdPersonCam = new _3rdPersonCam(game, (player.getPosition()), player, Vector3.Up, aspectRatio); flyByCam = new StaticCam(game, player, Vector3.Up, aspectRatio); firstPersonCam = new FirstPersonCam(game, player.getPosition(), Vector3.Up, aspectRatio); availableCameras = new Queue<Camera>(); availableCameras.Enqueue(thirdPersonCam); availableCameras.Enqueue(flyByCam); currentCam = availableCameras.Dequeue(); #endregion #region setup game objects cameras and draw order asteroidField = new AsteroidField(game, currentCam); game.Components.Add(asteroidField); player.setCamera(currentCam); player.DrawOrder = 3; moon.setCamera(currentCam); moon.DrawOrder = 3; skybox = new Skybox(game, currentCam, "Space"); skybox.DrawOrder = 1; game.Components.Add(skybox); #endregion #region initialize controls input = new Control(game, player, thirdPersonCam, false); game.Components.Add(input); #endregion collisonDetector = new Collision(game); game.Components.Add(collisonDetector); #region Audio //game.getMusicPlayer().playRandomTrack(); #endregion optionsHaveChanged(); }
/// <summary> /// M�todo que se llama una sola vez, al principio cuando se ejecuta el ejemplo. /// Escribir aqu� todo el c�digo de inicializaci�n: cargar modelos, texturas, modifiers, uservars, etc. /// Borrar todo lo que no haga falta /// </summary> public override void init() { //GuiController.Instance: acceso principal a todas las herramientas del Framework //Device de DirectX para crear primitivas Device d3dDevice = GuiController.Instance.D3dDevice; //Carpeta de archivos Media del alumno string alumnoMediaFolder = GuiController.Instance.AlumnoEjemplosMediaDir; /////////////////CONFIGURAR CAMARA PRIMERA PERSONA////////////////// ////Camara en primera persona, tipo videojuego FPS ////Solo puede haber una camara habilitada a la vez. Al habilitar la camara FPS se deshabilita la camara rotacional //////Por default la camara FPS viene desactivada //GuiController.Instance.FpsCamera.Enable = true; ////Configurar posicion y hacia donde se mira //GuiController.Instance.FpsCamera.setCamera(new Vector3(anchoPantalla / 2, altoPantalla / 2, anchoPantalla / 2), new Vector3(0, 0, 0)); string avionPath = GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\AvionCaza\\" + "AvionCaza-TgcScene.xml"; //Activamos el renderizado customizado. De esta forma el framework nos delega control total sobre como dibujar en pantalla //La responsabilidad cae toda de nuestro lado GuiController.Instance.CustomRenderEnabled = true; //Cargar shader de zbuffer effect = TgcShaders.loadEffect(GuiController.Instance.ExamplesMediaDir + "Shaders\\EjemploGetZBuffer.fx"); //Cargamos un escenario TgcSceneLoader loader = new TgcSceneLoader(); TgcScene scene = loader.loadSceneFromFile(avionPath); //cargo la mesh de la nube nube = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Jet_Pilot\\" + "Heightmaps\\" + "nube-TgcScene.xml").Meshes[0]; meshes = scene.Meshes; meshes.Add(nube); for (int i = 0; i < 8; i++) { nubes.Add(nube); } meshes.AddRange(nubes); //Le setea a todos los meshes de la scene el efecto de zbuffer foreach (TgcMesh mesh in meshes) { mesh.Effect = effect; } //Crear textura para almacenar el zBuffer. Es una textura que se usa como RenderTarget y que tiene un formato de 1 solo float de 32 bits. //En cada pixel no vamos a guardar un color sino el valor de Z de la escena //La creamos con un solo nivel de mipmap (el original) zBufferTexture = new Texture(d3dDevice, d3dDevice.Viewport.Width, d3dDevice.Viewport.Height, 1, Usage.RenderTarget, Format.R32F, Pool.Default); //Posicionar el avion meshes[0].Position = new Vector3(anchoPantalla / 2, altoPantalla / 2, anchoPantalla / 2); nube.Position = meshes[0].Position + new Vector3(10, 0, 0); //Camara en tercera persona que apunta al avion GuiController.Instance.ThirdPersonCamera.Enable = true; GuiController.Instance.ThirdPersonCamera.setCamera(meshes[0].Position, 20.0f, 150.0f); skyBox2 = new Skybox(); //Agrandamos la distancia del Far Plane para tener un skybox mas grande y que gracias a esto se dibuja y se ve d3dDevice.Transform.Projection = Matrix.PerspectiveFovLH(FastMath.ToRad(45.0f), 16 / 9, 10.0f, 50000.0f); ///////////////MODIFIERS////////////////// ////Crear un modifier para un valor FLOAT GuiController.Instance.Modifiers.addFloat("valorFloat", -50f, 200f, 0f); ////Crear un modifier para un ComboBox con opciones string[] opciones = new string[] { "opcion1", "opcion2", "opcion3" }; GuiController.Instance.Modifiers.addInterval("valorIntervalo", opciones, 0); ////Crear un modifier para modificar un v�rtice GuiController.Instance.Modifiers.addVertex3f("valorVertice", new Vector3(-1000, -1000, -1000), new Vector3(5000, 5000, 5000), new Vector3((anchoPantalla / 2) - 20, (altoPantalla / 2) - 100, anchoPantalla / 2)); }
public override void Initialize() { float aspectRatio = game.GraphicsDevice.Viewport.AspectRatio; #region Load Models //Load Models Vector3 initPlayerPosition = new Vector3(-500, 550, 500); player = new Player(game, initPlayerPosition, 5f); terrain = new Terrain(game); game.Components.Add(player); game.Components.Add(terrain); #endregion #region Load Cameras //Load Cameras thirdPersonCam = new _3rdPersonCam(game, (player.getPosition()), player, Vector3.Up, aspectRatio); flyByCam = new StaticCam(game, player, Vector3.Up, aspectRatio); firstPersonCam = new FirstPersonCam(game, player.getPosition(), Vector3.Up, aspectRatio); availableCameras = new Queue<Camera>(); availableCameras.Enqueue(thirdPersonCam); availableCameras.Enqueue(flyByCam); currentCam = availableCameras.Dequeue(); #endregion #region setup game objects cameras and draw order player.setCamera(currentCam); player.DrawOrder = 3; terrain.setCamera(currentCam); terrain.DrawOrder = 2; skybox = new Skybox(game, currentCam, "Space"); skybox.DrawOrder = 1; game.Components.Add(skybox); #endregion #region initialize controls input = new Control(game, player, thirdPersonCam, false); game.Components.Add(input); #endregion collisionDetector = new Collision(game); game.Components.Add(collisionDetector); terrainCollisionDetector = new TerrainCollision(game, terrain); game.Components.Add(terrainCollisionDetector); #region Records //places records on the land scape randomly Random rand = new Random(); for (int i = 0; i < 10; i++) { Vector3 pos = new Vector3(rand.Next(-255*30, 0), 0, rand.Next(0, 255*30 )); pos.Y = terrain.getTerrainHeight(pos) + 30; Record newRecord = new Record(game, pos); recordList.Add(newRecord); newRecord.setCamera(currentCam); newRecord.DrawOrder = 3; game.Components.Add(newRecord); } #endregion optionsHaveChanged(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); skyboxTextureName = "SkyBox1"; skyboxTexture = Content.Load<TextureCube>("Skyboxes/" + skyboxTextureName); model = Content.Load<Model>("Models/UntexturedSphere"); effect = Content.Load<Effect>("Effects/Reflection"); skybox = new Skybox("Skyboxes/" + skyboxTextureName, Content); }
private void setSky(Skybox s){ RenderSettings.skybox.SetColor("_Color1", s.color1); RenderSettings.skybox.SetColor("_Color2", s.color2); RenderSettings.skybox.SetColor("_Color3", s.color3); RenderSettings.skybox.SetFloat("_Exponent1", s.exponent1); RenderSettings.skybox.SetFloat("_Exponent2", s.exponent2); RenderSettings.skybox.SetFloat("_Intensity", s.intensity); }
//"time" is number of degrees it takes to finish changing to new sky //if time is 0, change sky immediately; time should not be less than 0 //currently unused private void changeSkyByTime(Skybox s, float time){ skyGoal = s; if(time <= 0){ timeRemain = 0; setSky(skyGoal); }else{ timeRemain = time * timeresPerDegree; skyDelta = s - getSky() / timeRemain; } }
void Start() { skybox = GetComponent<Skybox>(); camera = GetComponent<Camera>(); audioDirector = FindObjectOfType<AudioDirectorScript>(); }
void Start () { _skybox = GetComponent<Skybox> (); }
public override void OnInspectorGUI() { Camera[] cams = Camera.allCameras; bool sceneHasCamera = cams.Length > 0; if (Camera.mainCamera) { sceneCamera = Camera.mainCamera; } else if (sceneHasCamera) { sceneCamera = cams[0]; } if (sceneCamera != null) if (sceneCameraSkybox == null) sceneCameraSkybox = sceneCamera.GetComponent<Skybox>(); if (pointPreviewTexture == null) pointPreviewTexture = new RenderTexture(400, Mathf.RoundToInt(400 / aspect), 24); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Name:", GUILayout.Width(50)); bezierControlPoint.name = EditorGUILayout.TextField(bezierControlPoint.name); EditorGUILayout.EndHorizontal(); if ((EditorGUIUtility.isProSkin) && bezier.numberOfCurves > 0 && pointPreviewTexture != null) { bool cameraPathPreview = EditorPrefs.GetBool("CameraPathPreview"); GUILayout.Space(7); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Point Preview"); if (cameraPathPreview) { if (GUILayout.Button("Hide", GUILayout.Width(50))) EditorPrefs.SetBool("CameraPathPreview", false); } else { if (GUILayout.Button("Show", GUILayout.Width(50))) EditorPrefs.SetBool("CameraPathPreview", true); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); if (!Application.isPlaying && EditorPrefs.GetBool("CameraPathPreview")) { if (animator.animationTarget == null) { EditorGUILayout.HelpBox("No animation target has been specified so there is nothing to animate. Select an animation target in the Camera Path Bezier Animator Component in the parent clip", MessageType.Warning); return; } previewCamPos = bezierControlPoint.transform.position; previewCamRot = Quaternion.identity; previewCamFOV = bezierControlPoint.FOV; Vector3 plusPoint, minusPoint; float pointPercentage = bezier.GetPathPercentageAtPoint(bezierControlPoint); switch (bezier.mode) { case CameraPathBezier.viewmodes.usercontrolled: previewCamRot = bezierControlPoint.transform.rotation; break; case CameraPathBezier.viewmodes.target: if (bezier.target != null) { previewCamRot = Quaternion.LookRotation(bezier.target.transform.position - bezierControlPoint.transform.position); } else { EditorGUILayout.HelpBox("No target has been specified in the bezier path", MessageType.Warning); previewCamRot = Quaternion.identity; } break; case CameraPathBezier.viewmodes.followpath: minusPoint = bezier.GetPathPosition(Mathf.Clamp01(pointPercentage - 0.05f)); plusPoint = bezier.GetPathPosition(Mathf.Clamp01(pointPercentage + 0.05f)); previewCamRot = Quaternion.LookRotation(plusPoint - minusPoint); break; case CameraPathBezier.viewmodes.reverseFollowpath: minusPoint = bezier.GetPathPosition(Mathf.Clamp01(pointPercentage - 0.05f)); plusPoint = bezier.GetPathPosition(Mathf.Clamp01(pointPercentage + 0.05f)); previewCamRot = Quaternion.LookRotation(minusPoint - plusPoint); break; case CameraPathBezier.viewmodes.mouselook: Vector3 minusPointb = bezier.GetPathPosition(Mathf.Clamp01(pointPercentage - 0.05f)); Vector3 plusPointb = bezier.GetPathPosition(Mathf.Clamp01(pointPercentage + 0.05f)); previewCamRot = Quaternion.LookRotation(plusPointb - minusPointb); break; } GameObject cam = new GameObject("Point Preview"); cam.AddComponent<Camera>(); if (sceneCamera != null) { cam.camera.backgroundColor = sceneCamera.backgroundColor; if (sceneCameraSkybox != null) cam.AddComponent<Skybox>().material = sceneCameraSkybox.material; else if (RenderSettings.skybox != null) cam.AddComponent<Skybox>().material = RenderSettings.skybox; } cam.transform.position = previewCamPos; cam.transform.rotation = previewCamRot; cam.camera.fov = previewCamFOV; cam.camera.targetTexture = pointPreviewTexture; cam.camera.Render(); cam.camera.targetTexture = null; DestroyImmediate(cam); Rect previewRect = new Rect(0, 0, Screen.width, Screen.width / aspect); Rect layoutRect = EditorGUILayout.BeginVertical(); previewRect.x = layoutRect.x; previewRect.y = layoutRect.y + 5; EditorGUI.DrawPreviewTexture(previewRect, pointPreviewTexture); GUILayout.Space(previewRect.height + 10); EditorGUILayout.EndVertical(); } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("The control point modifies the curve. Resetting it will centre it and there will be no curve. Useful if you don't want there to be a curve at this point", MessageType.Info); if (GUILayout.Button("Reset Control Point")) { Undo.RegisterUndo(bezierControlPoint.gameObject, "Reset Control Point"); bezierControlPoint.controlPoint = Vector3.zero; EditorUtility.SetDirty(bezierControlPoint); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("Make the rotation of the Control Point face the direction the path is going in at this point", MessageType.Info); if (GUILayout.Button("Face Path Direction")) { Undo.RegisterUndo(bezierControlPoint.gameObject.transform, "Set Control Point Rotation to Path Direction"); bezierControlPoint.SetRotationToCurve(); EditorUtility.SetDirty(bezierControlPoint); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); if (!bezierControlPoint.isLastPoint || bezier.loop) { EditorGUILayout.HelpBox("This controls the easing applied from this point to the next.", MessageType.Info); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Animation Ease"); bezierControlPoint.ease = (CameraPathBezierControlPoint.animationEase)EditorGUILayout.EnumPopup(bezierControlPoint.ease); EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("The last control point does not have easing options as there is no following curve.", MessageType.Info); } bezierControlPoint.controlPoint = EditorGUILayout.Vector3Field("Control Point Location", bezierControlPoint.controlPoint); // GUILayout.Space(7); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Field of View"); bezierControlPoint.FOV = EditorGUILayout.Slider(bezierControlPoint.FOV, 1, 180); EditorGUILayout.EndHorizontal(); GUILayout.Space(7); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Delay"); bezierControlPoint.delayMode = (CameraPathBezierControlPoint.DELAY_MODES)EditorGUILayout.EnumPopup(bezierControlPoint.delayMode); EditorGUILayout.EndHorizontal(); if (bezierControlPoint.delayMode == CameraPathBezierControlPoint.DELAY_MODES.timed) { GUILayout.Space(7); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Time of delay"); bezierControlPoint.delayTime = EditorGUILayout.FloatField(bezierControlPoint.delayTime, GUILayout.Width(50)); EditorGUILayout.LabelField("secs", GUILayout.Width(30)); EditorGUILayout.EndHorizontal(); } if (bezier.mode == CameraPathBezier.viewmodes.followpath || bezier.mode == CameraPathBezier.viewmodes.reverseFollowpath) { GUILayout.Space(7); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Tilt", GUILayout.Width(40)); bezierControlPoint.tilt = EditorGUILayout.Slider(bezierControlPoint.tilt, -180, 180); EditorGUILayout.EndHorizontal(); } if (GUI.changed) { bezier.RecalculateStoredValues(); EditorUtility.SetDirty(bezierControlPoint); EditorUtility.SetDirty(bezier); EditorUtility.SetDirty(animator); } }
public override void OnInspectorGUI() { Camera[] cams = Camera.allCameras; bool sceneHasCamera = cams.Length>0; if(Camera.mainCamera){ sceneCamera = Camera.mainCamera; }else if(sceneHasCamera){ sceneCamera = cams[0]; } if(sceneCamera!=null) if(sceneCameraSkybox==null) sceneCameraSkybox = sceneCamera.GetComponent<Skybox>(); if(pointPreviewTexture==null) pointPreviewTexture = new RenderTexture(400, Mathf.RoundToInt(400/aspect), 24); if(animator.animationTarget==null){ EditorGUILayout.HelpBox("No animation target has been specified so there is nothing to animate. Select an animation target in the Camera Path Bezier Animator Component in the parent clip",MessageType.Warning); }else{ if((EditorGUIUtility.isProSkin) && bezier.numberOfCurves > 0 && pointPreviewTexture!=null){ bool cameraPathPreview = EditorPrefs.GetBool("CameraPathPreview"); GUILayout.Space(7); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Animation Preview"); if(cameraPathPreview) { if(GUILayout.Button("Hide", GUILayout.Width(50))) EditorPrefs.SetBool("CameraPathPreview", false); }else{ if(GUILayout.Button("Show", GUILayout.Width(50))) EditorPrefs.SetBool("CameraPathPreview", true); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); if(!Application.isPlaying && cameraPathPreview){ float usePercentage = animator.normalised? animator.RecalculatePercentage(animator.editorTime): animator.editorTime; //Get animation values and apply them to the preview camera previewCamPos = bezier.GetPathPosition(usePercentage); previewCamRot = Quaternion.identity; previewCamFOV = bezier.GetPathFOV(usePercentage); //Assign rotation to preview camera Vector3 plusPoint, minusPoint; switch(bezier.mode) { case CameraPathBezier.viewmodes.usercontrolled: previewCamRot = bezier.GetPathRotation(usePercentage); break; case CameraPathBezier.viewmodes.target: if(bezier.target != null){ previewCamRot = Quaternion.LookRotation(bezier.target.transform.position - previewCamPos); }else{ EditorGUILayout.HelpBox("No target has been specified in the bezier path",MessageType.Warning); previewCamRot = Quaternion.identity; } break; case CameraPathBezier.viewmodes.followpath: minusPoint = bezier.GetPathPosition(Mathf.Clamp01(usePercentage-0.05f)); plusPoint = bezier.GetPathPosition(Mathf.Clamp01(usePercentage+0.05f)); previewCamRot = Quaternion.LookRotation(plusPoint-minusPoint); break; case CameraPathBezier.viewmodes.reverseFollowpath: minusPoint = bezier.GetPathPosition(Mathf.Clamp01(usePercentage-0.05f)); plusPoint = bezier.GetPathPosition(Mathf.Clamp01(usePercentage+0.05f)); previewCamRot = Quaternion.LookRotation(minusPoint-plusPoint); break; case CameraPathBezier.viewmodes.mouselook: Vector3 minusPointb = bezier.GetPathPosition(Mathf.Clamp01(usePercentage-0.05f)); Vector3 plusPointb = bezier.GetPathPosition(Mathf.Clamp01(usePercentage+0.05f)); previewCamRot = Quaternion.LookRotation(plusPointb-minusPointb); break; } //Render the camera preview GameObject cam = new GameObject("Point Preview"); cam.transform.parent = bezier.transform; cam.AddComponent<Camera>(); //Retreive camera settings from the main camera if(sceneCamera!=null){ cam.camera.backgroundColor = sceneCamera.backgroundColor; if(sceneCameraSkybox!=null) cam.AddComponent<Skybox>().material = sceneCameraSkybox.material; else if(RenderSettings.skybox!=null) cam.AddComponent<Skybox>().material = RenderSettings.skybox; } cam.transform.position = previewCamPos; cam.transform.rotation = previewCamRot; cam.camera.fov = previewCamFOV; cam.camera.targetTexture = pointPreviewTexture; cam.camera.Render(); cam.camera.targetTexture = null; DestroyImmediate(cam); //Display the camera preview Rect previewRect = new Rect(0,0, Screen.width, Screen.width/aspect); Rect layoutRect = EditorGUILayout.BeginVertical(); previewRect.x = layoutRect.x; previewRect.y = layoutRect.y+5; EditorGUI.DrawPreviewTexture(previewRect, pointPreviewTexture); GUILayout.Space(previewRect.height+10); pointPreviewTexture.Release(); EditorGUILayout.BeginHorizontal(); float time = EditorGUILayout.Slider(animator.editorTime*animator.pathTime,0,animator.pathTime); animator.editorTime = time/animator.pathTime; EditorGUILayout.LabelField("sec",GUILayout.Width(25)); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } } animator.showScenePreview = EditorGUILayout.Toggle("Show Scene Preview Info", animator.showScenePreview); animator.playOnStart = EditorGUILayout.Toggle("Play on start", animator.playOnStart); EditorGUILayout.BeginHorizontal(); animator.pathTime = EditorGUILayout.FloatField("Animation Time",animator.pathTime); EditorGUILayout.LabelField("sec",GUILayout.Width(25)); EditorGUILayout.EndHorizontal(); bool noPath = bezier.numberOfControlPoints<2; EditorGUI.BeginDisabledGroup(noPath); EditorGUILayout.BeginHorizontal(); float newPathSpeed = EditorGUILayout.FloatField("Animation Speed",animator.pathSpeed); if(!noPath) animator.pathSpeed = newPathSpeed; EditorGUILayout.LabelField("m/sec",GUILayout.Width(25)); EditorGUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); animator.pathTime = Mathf.Max(animator.pathTime,0.001f);//ensure it's a real number animator.animationTarget = (Transform)EditorGUILayout.ObjectField("Animate Object",animator.animationTarget, typeof(Transform),true); EditorGUILayout.HelpBox("This toggle can be used to specify what kind of object you are animating. If it isn't a camera, we recommend you uncheck this box",MessageType.Info); animator.isCamera = EditorGUILayout.Toggle("Is Camera", animator.isCamera); animator.mode = (CameraPathBezierAnimator.modes)EditorGUILayout.EnumPopup("Animation Mode",animator.mode); animator.normalised = EditorGUILayout.Toggle("Normalised Path",animator.normalised); EditorGUILayout.HelpBox("Set this if you want to start another camera path animation once this has completed",MessageType.Info); animator.nextAnimation = (CameraPathBezierAnimator)EditorGUILayout.ObjectField("Next Camera Path",animator.nextAnimation, typeof(CameraPathBezierAnimator),true); if(bezier.mode == CameraPathBezier.viewmodes.mouselook) { EditorGUILayout.HelpBox("Alter the mouse sensitivity here",MessageType.Info); animator.sensitivity = EditorGUILayout.Slider("Mouse Sensitivity",animator.sensitivity,0.1f, 2.0f); EditorGUILayout.HelpBox("Restrict the vertical viewable area here.",MessageType.Info); EditorGUILayout.LabelField("Mouse Y Restriction"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(((int)animator.minX).ToString(),GUILayout.Width(30)); EditorGUILayout.MinMaxSlider(ref animator.minX, ref animator.maxX, -180, 180); EditorGUILayout.LabelField(((int)animator.maxX).ToString(),GUILayout.Width(30)); EditorGUILayout.EndHorizontal(); } if (GUI.changed) { bezier.RecalculateStoredValues(); EditorUtility.SetDirty (animator); EditorUtility.SetDirty (bezier); } }
void Awake() { _cachedTransform = transform; _cachedSkyBox = GetComponent<Skybox>(); _cachedSkyBox.material = _skyBoxList[0]; }
// Use this for initialization void Start () { // reference components skybox = GetComponent<Skybox>(); }