public DrawGridParameters PrepareGridRender(Camera camera, Vector3 pivot, Quaternion rotation, float size, bool orthoMode, bool gridVisible) { bool flag1 = false; bool flag2 = false; bool flag3 = false; if (gridVisible) { if (orthoMode) { Vector3 vector3 = rotation * Vector3.forward; if ((double) Mathf.Abs(vector3.y) > 0.200000002980232) flag2 = true; else if (vector3 == Vector3.left || vector3 == Vector3.right) flag1 = true; else if (vector3 == Vector3.forward || vector3 == Vector3.back) flag3 = true; } else flag2 = true; } this.xGrid.target = flag1; this.yGrid.target = flag2; this.zGrid.target = flag3; DrawGridParameters drawGridParameters; drawGridParameters.pivot = pivot; drawGridParameters.color = (Color) SceneViewGrid.kViewGridColor; drawGridParameters.size = size; drawGridParameters.alphaX = this.xGrid.faded; drawGridParameters.alphaY = this.yGrid.faded; drawGridParameters.alphaZ = this.zGrid.faded; return drawGridParameters; }
void Start() { m_Cam = GetComponent<Camera>(); m_OriginalRotation = transform.localRotation; this.UpdateAsObservable() .Where(_ => GameState.Instance.GameStateReactiveProperty.Value == GameStateEnum.Countdown || GameState.Instance.GameStateReactiveProperty.Value == GameStateEnum.GameUpdate) .Select(_ => { var playerPos = PlayerManager.Instance.GetAlivePlayers() .Select(x => x.transform.position); var _x = playerPos.Average(x => x.x); var _y = playerPos.Average(x => x.y); var _z = playerPos.Average(x => x.z); tergetPos = new Vector3(_x, _y, _z); return tergetPos; }).DelayFrame(3) .Subscribe(target => { var campos = tergetPos + m_defaultPosition; transform.position = Vector3.Lerp(this.transform.position, campos, Time.deltaTime * 5.0f); // transform.LookAt(target - this.transform.position); }); }
public static Axis CalcDragAxis(Vector3 movement, Camera cam) { Vector3 mask = VectorToMask(movement); if(mask.x + mask.y + mask.z == 2) { return MaskToAxis(Vector3.one - mask); } else { switch( MaskToAxis(mask) ) { case Axis.X: if( Mathf.Abs(Vector3.Dot(cam.transform.forward, Vector3.up)) < Mathf.Abs(Vector3.Dot(cam.transform.forward, Vector3.forward))) return Axis.Z; else return Axis.Y; case Axis.Y: if( Mathf.Abs(Vector3.Dot(cam.transform.forward, Vector3.right)) < Mathf.Abs(Vector3.Dot(cam.transform.forward, Vector3.forward))) return Axis.Z; else return Axis.X; case Axis.Z: if( Mathf.Abs(Vector3.Dot(cam.transform.forward, Vector3.right)) < Mathf.Abs(Vector3.Dot(cam.transform.forward, Vector3.up))) return Axis.Y; else return Axis.X; default: return Axis.None; } } }
/// <summary> /// Does the align. /// </summary> protected virtual void DoAlign() { if (alignCamera == null) alignCamera = Camera.main; // Just assume y value is centre, we could refine this for 3D with perspective by translation objects y position to scren position. Vector3 point = alignCamera.ScreenToWorldPoint (new Vector3(0, alignCamera.pixelHeight / 2.0f, -alignCamera.transform.position.z)); transform.position = new Vector3 (point.x + offset, transform.position.y, transform.position.z); }
public HUDCompass(Camera camera) { compassCamera = camera; HorizontalAlignment = HorizontalAlignment.Right; VerticalAlignment = VerticalAlignment.Bottom; LoadAssets(); }
public PreviewRenderUtility(bool renderFullScene) { GameObject gameObject = EditorUtility.CreateGameObjectWithHideFlags("PreRenderCamera", HideFlags.HideAndDontSave, new Type[] { typeof(Camera) }); this.m_Camera = gameObject.GetComponent<Camera>(); this.m_Camera.fieldOfView = this.m_CameraFieldOfView; this.m_Camera.enabled = false; this.m_Camera.clearFlags = CameraClearFlags.Depth; this.m_Camera.farClipPlane = 10f; this.m_Camera.nearClipPlane = 2f; this.m_Camera.backgroundColor = new Color(0.192156866f, 0.192156866f, 0.192156866f, 1f); this.m_Camera.renderingPath = RenderingPath.Forward; this.m_Camera.useOcclusionCulling = false; if (!renderFullScene) { Handles.SetCameraOnlyDrawMesh(this.m_Camera); } for (int i = 0; i < 2; i++) { GameObject gameObject2 = EditorUtility.CreateGameObjectWithHideFlags("PreRenderLight", HideFlags.HideAndDontSave, new Type[] { typeof(Light) }); this.m_Light[i] = gameObject2.GetComponent<Light>(); this.m_Light[i].type = LightType.Directional; this.m_Light[i].intensity = 1f; this.m_Light[i].enabled = false; } this.m_Light[0].color = SceneView.kSceneViewFrontLight; this.m_Light[1].transform.rotation = Quaternion.Euler(340f, 218f, 177f); this.m_Light[1].color = new Color(0.4f, 0.4f, 0.45f, 0f) * 0.7f; }
public override void SetupCameraEvents(Camera _cam, RenderSystem _system) { var _evt = CameraEvent.AfterForwardAlpha; var _cmdBuf = GetCommandBufferForEvent(_cam, _evt, "MGFX.VolLine"); _cmdBuf.Clear(); var system = VolumetricLineSystem.instance; var propPt0 = Shader.PropertyToID("_VolLinePoint0"); var propPt1 = Shader.PropertyToID("_VolLinePoint1"); var propCol = Shader.PropertyToID("_VolLineColor"); var propRad = Shader.PropertyToID("_VolLineRadius"); Vector3 valPt0 = Vector3.zero; Vector3 valPt1 = Vector3.zero; Color valCol = Color.white; float valRad = 0; Matrix4x4 _m, _p; var _lut = m_LookUpTable; m_MaterialVolLine.SetTexture("_VolLineLUT", _lut); foreach (var _line in system.m_Lines) { valRad = _line.GetRenderMatrics(out _m, out _p); _line.GetPoints(_p, out valPt0, out valPt1); valCol = _line.GetLinearColor(); _cmdBuf.SetGlobalVector(propPt0, valPt0); _cmdBuf.SetGlobalVector(propPt1, valPt1); _cmdBuf.SetGlobalColor(propCol, valCol); _cmdBuf.SetGlobalFloat(propRad, valRad); _cmdBuf.DrawMesh(m_CubeMesh, _m, m_MaterialVolLine, 0, 0); } }
public override void OnEnter() { var go = Fsm.GetOwnerDefaultTarget(camera); if (go == null) { _cam = Camera.mainCamera; }else{ Camera _camera = go.camera; if (_camera == null) { LogError("Missing Camera Component!"); Finish(); return; }else{ _cam = _camera; } } DoRaycastFromScreen(); if (repeatInterval.Value == 0) { Finish(); } }
// Use this for initialization private void Start() { if (Application.loadedLevelName == "Sanctuary") { Sprint = true; m_WalkSpeed = 5; m_RunSpeed = 10; } else { m_WalkSpeed = GetComponent<combatStats>().walkSpeed; m_RunSpeed = GetComponent<combatStats>().runSpeed; m_CrouchSpeed = GetComponent<combatStats>().crouchSpeed; } m_CharacterController = GetComponent<CharacterController>(); m_Camera = Camera.main; m_OriginalCameraPosition = m_Camera.transform.localPosition; m_FovKick.Setup(m_Camera); m_HeadBob.Setup(m_Camera, m_StepInterval); m_StepCycle = 0f; m_NextStep = m_StepCycle/2f; m_Jumping = false; m_AudioSource = GetComponent<AudioSource>(); m_MouseLook.Init(transform , m_Camera.transform); }
void Awake() { playerGameObject.transform.position = new Vector3(229, 1000, 5897); t_Camera = Camera.main; }
public void Init(Camera _cam) { cam = _cam; Rect pr = GVScreen.DisplayRect; cam.pixelRect = new Rect(pr.x, Screen.height - pr.yMax, pr.width, pr.height); }
private void OnEnable() { rb = GetComponent<Rigidbody>(); activeCamera = GameObject.Find("Scene Camera").GetComponent<Camera>(); gesture = GetComponent<TapGesture>(); gesture.Tapped += tappedHandler; }
private void Awake() { _selectionVisualCamera = this.GetComponentInChildren<Camera>(); _selectionVisual = this.GetComponentInChildren<MeshRenderer>().transform; ToggleEnabled(false); }
public void WaterTileBeingRendered(Transform tr, Camera currentCam) { if (currentCam && edgeBlend) { currentCam.depthTextureMode |= DepthTextureMode.Depth; } }
private void Start() { _cameraTransform = transform; _mapRenderer = GameObject.Find("BaseMap").GetComponent<SpriteRenderer>(); _bounds = _mapRenderer.sprite.bounds; _bounds.center = _mapRenderer.transform.position; _cameraTransform.position = new Vector3(_mapRenderer.transform.position.x, _mapRenderer.transform.position.y, -10); _basePosition = _cameraTransform.position; _offset = Vector3.zero; _camera = GetComponent<UnityEngine.Camera>(); _windowaspect = (float)Screen.width / (float)Screen.height; _widthSize = _camera.orthographicSize * _windowaspect; SetBounds(_camera.orthographicSize); _camera.orthographicSize = _maxZoom; _zoom = _maxZoom; _pixelToUnitX = _widthSize * 2 / (float)Screen.width; _pixelToUnitY = _camera.orthographicSize * 2 / (float)Screen.height; }
void Start() { if (GetComponent<Rigidbody>()) { GetComponent<Rigidbody>().freezeRotation = true; } _camera = GetComponentInChildren<Camera> (); }
/// <summary> /// adds an offset to the cameras position each frame. shakeIntensity is degraded by shadeDegradation each frame until it nears 0. /// Once it reaches 0 the tween is removed from ZestKit. You can reuse it at anytime by just calling the shake method. /// /// </summary> /// <param name="camera">the Camera to shake</param> /// <param name="shakeIntensity">how much should we shake it</param> /// <param name="shakeDegredation">higher values cause faster degradation</param> /// <param name="shakeDirection">Vector3.zero will result in a shake on just the x/y axis. any other values will result in the passed /// in shakeDirection * intensity being the offset the camera is moved</param> public CameraShakeTween( Camera camera, float shakeIntensity = 0.3f, float shakeDegredation = 0.95f, Vector3 shakeDirection = default( Vector3 ) ) { _cameraTransform = camera.transform; _shakeIntensity = shakeIntensity; _shakeDegredation = shakeDegredation; _shakeDirection = shakeDirection.normalized; }
protected virtual void Awake() { // Straightforward things happening here PointerEventDataCache = new PointerEventData(FindObjectOfType<EventSystem>()); UiRootCamera = Camera.main; }
//private int MaskLayer; // excludes hits to only objects here. //private float RayDistance; public HitManager(Camera asSeenByCamera) { Hit = new RaycastHit(); //RayDistance = Mathf.Infinity; //MaskLayer = Physics.kDefaultRaycastLayers; SetHitCamera(asSeenByCamera); }
/// <summary> /// calculate the area in which we draw the GUI, considering the current anchor option /// </summary> /// <param name="anchor">In what area of the scene view we should draw</param> /// <param name="sceneCamera">The camera of the scene view in which we render the GUI</param> /// <returns>the GUI area in the appropriate anchor position</returns> private static Rect CalculateGuiRect(TextAnchor anchor, Camera sceneCamera) { switch (anchor) { case TextAnchor.UpperLeft: return new Rect(GUI_AREA_MARGIN, GUI_AREA_MARGIN, WIDTH, HEIGHT); case TextAnchor.UpperCenter: return new Rect((sceneCamera.pixelWidth / 2f) - (WIDTH / 2f), GUI_AREA_MARGIN, WIDTH, HEIGHT); case TextAnchor.UpperRight: return new Rect((sceneCamera.pixelWidth - WIDTH - GUI_AREA_MARGIN) - UNITY_GIZMO_WIDTH, GUI_AREA_MARGIN, WIDTH, HEIGHT); case TextAnchor.MiddleLeft: return new Rect(GUI_AREA_MARGIN, (sceneCamera.pixelHeight / 2f) - (HEIGHT / 2f), WIDTH, HEIGHT); case TextAnchor.MiddleCenter: return new Rect((sceneCamera.pixelWidth / 2f) - (WIDTH / 2f), (sceneCamera.pixelHeight / 2f) - (HEIGHT / 2f), WIDTH, HEIGHT); case TextAnchor.MiddleRight: return new Rect((sceneCamera.pixelWidth - WIDTH - GUI_AREA_MARGIN), (sceneCamera.pixelHeight / 2f) - (HEIGHT / 2f), WIDTH, HEIGHT); case TextAnchor.LowerLeft: return new Rect(GUI_AREA_MARGIN, (sceneCamera.pixelHeight - HEIGHT - GUI_AREA_MARGIN), WIDTH, HEIGHT); case TextAnchor.LowerCenter: return new Rect((sceneCamera.pixelWidth / 2f) - (WIDTH / 2f), (sceneCamera.pixelHeight - HEIGHT - GUI_AREA_MARGIN), WIDTH, HEIGHT); case TextAnchor.LowerRight: return new Rect((sceneCamera.pixelWidth - WIDTH - GUI_AREA_MARGIN), (sceneCamera.pixelHeight - HEIGHT - GUI_AREA_MARGIN), WIDTH, HEIGHT); default: goto case TextAnchor.UpperLeft; } }
public Minimap() { // Init minimap m_gameObject = new GameObject(); m_icons = new List<MinimapIcon>(); m_origBounds = new Rect(1920 - 224, 16, 209, 184); UpdateBounds(); // Create the minimap render texture m_minimap = (Material)UnityEngine.Resources.Load("textures/minimapRT"); // Create Camera m_camera = m_gameObject.AddComponent<Camera>(); m_camera.isOrthoGraphic = true; m_camera.orthographicSize = 500f; m_camera.nearClipPlane = 10f; m_camera.farClipPlane = 1000f; m_camera.clearFlags = CameraClearFlags.Color; m_camera.backgroundColor = Color.black; m_camera.targetTexture = (RenderTexture)m_minimap.mainTexture; m_camera.rect = new Rect(0f, 0f, 1f, 1f); m_camera.cullingMask = 1 << LayerMask.NameToLayer("Terrain"); m_gameObject.transform.position = new Vector3(0f, 100f, 0f); m_gameObject.transform.eulerAngles = new Vector3(90f, 0f, 0f); m_gameObject.layer = LayerMask.NameToLayer("Minimap"); m_gameObject.name = "Minimap"; }
protected virtual void Awake() { // Straightforward things happening here PointerEventDataCache = new PointerEventData(FindObjectOfType<EventSystem>()); UiRootCamera = GetComponentInParent<Canvas>().worldCamera; }
public void RenderHelpCameras(Camera currentCam) { if (null == m_HelperCameras) { m_HelperCameras = new Dictionary<Camera, bool>(); } if (!m_HelperCameras.ContainsKey(currentCam)) { m_HelperCameras.Add(currentCam, false); } if (m_HelperCameras[currentCam]) { return; } if (!m_ReflectionCamera) { m_ReflectionCamera = CreateReflectionCameraFor(currentCam); } RenderReflectionFor(currentCam, m_ReflectionCamera); m_HelperCameras[currentCam] = true; }
Camera CreateReflectionCameraFor(Camera cam) { String reflName = gameObject.name + "Reflection" + cam.name; GameObject go = GameObject.Find(reflName); if (!go) { go = new GameObject(reflName, typeof(Camera)); } if (!go.GetComponent(typeof(Camera))) { go.AddComponent(typeof(Camera)); } Camera reflectCamera = go.GetComponent<Camera>(); reflectCamera.backgroundColor = clearColor; reflectCamera.clearFlags = reflectSkybox ? CameraClearFlags.Skybox : CameraClearFlags.SolidColor; SetStandardCameraParameter(reflectCamera, reflectionMask); if (!reflectCamera.targetTexture) { reflectCamera.targetTexture = CreateTextureFor(cam); } return reflectCamera; }
RenderTexture CreateTextureFor(Camera cam) { RenderTexture rt = new RenderTexture(Mathf.FloorToInt(cam.pixelWidth * 0.5F), Mathf.FloorToInt(cam.pixelHeight * 0.5F), 24); rt.hideFlags = HideFlags.DontSave; return rt; }
public void Setup(Camera camera) { CheckStatus(camera); Camera = camera; OriginalFOV = camera.fieldOfView; }
public void DragSelectionBox(Camera main, CursorPanGroup group, CursorButton button, TutorialAIManager manager, float delayTime, string methodName) { BoxSelector selector = main.GetComponent<BoxSelector>(); if (selector == null) { Debug.LogError("Cannot find Box Selector component from camera, " + main.ToString() + "."); return; } if (button != CursorButton.Left_Click) { Debug.LogError("Selection box only works with left mouse button."); return; } selector.StartBoxSelection(group, 0.5f); this.icon.SetButton(button); this.buttonPressedElapsedTime = 0f; this.isButtonPressed = true; this.isButtonHeld = true; this.isAppearing = true; this.panningElapsedTime = 0f; this.startingPosition = group.start; this.endingPosition = group.end; this.rectTransform.position = group.start; manager.Invoke(methodName, delayTime); this.Invoke("HeldButtonRelease", delayTime); }
public override void OnEnter() { _go = Fsm.GetOwnerDefaultTarget(camera); if (_go == null) { LogError("Missing gameObject!"); return; } if (_go.camera == null) { LogError("Missing camera!"); return; } oldCamera = Camera.main; SwitchCamera(Camera.main, _go.camera); if (makeMainCamera) _go.camera.tag = "MainCamera"; Finish(); }
public override void OnSceneGUI() { var setCameraFOVAction = (HutongGames.PlayMaker.Actions.SetCameraFOV)target; if (setCameraFOVAction.fieldOfView.IsNone) { return; } var go = setCameraFOVAction.Fsm.GetOwnerDefaultTarget(setCameraFOVAction.gameObject); var fov = setCameraFOVAction.fieldOfView.Value; if (go != null && fov > 0) { if (go != cachedGameObject || camera == null) { camera = go.GetComponent<Camera>(); cachedGameObject = go; } if (camera != null) { var originalFOV = camera.fieldOfView; camera.fieldOfView = setCameraFOVAction.fieldOfView.Value; Handles.color = new Color(1, 1, 0, .5f); SceneGUI.DrawCameraFrustrum(camera); camera.fieldOfView = originalFOV; } } }
public void Awake() { _transform = transform; // Find player camera controller PlayerCameraController cameraController = FindObjectOfType<PlayerCameraController>(); if (cameraController == null) { Debug.LogWarning("Either no player camera controller present within the scene, or Player script is unable to find it"); } else { // Get player camera _playerCamera = cameraController.GetComponentInChildren<Camera>(); if (_playerCamera == null) { Debug.LogWarning("Player script is unable to find the player camera"); } } // Ensure player is able to trigger explsions if (_explosionsAmount <= 0) { Debug.LogWarning("Player will not be able to trigger explosions, with current explosion count"); } if (_explodableLayers.value == 0) { Debug.LogWarning("Player will not be able to trigger explosions, with current explodable layers settings"); } }
public bool Connect(Config config) { IntPtr unityCameraTexture = IntPtr.Zero; if (config.CapturerType == CapturerType.UnityCamera) { unityCamera = config.UnityCamera; var texture = new UnityEngine.RenderTexture(config.VideoWidth, config.VideoHeight, 0, UnityEngine.RenderTextureFormat.BGRA32); unityCamera.targetTexture = texture; unityCamera.enabled = true; unityCameraTexture = texture.GetNativeTexturePtr(); } var role = config.Role == Role.Sendonly ? "sendonly" : config.Role == Role.Recvonly ? "recvonly" : "sendrecv"; return(sora_connect( p, UnityEngine.Application.unityVersion, config.SignalingUrl, config.ChannelId, config.Metadata, role, config.Multistream, (int)config.CapturerType, unityCameraTexture, config.VideoCapturerDevice, config.VideoWidth, config.VideoHeight, config.VideoCodec.ToString(), config.VideoBitrate, config.UnityAudioInput, config.UnityAudioOutput, config.AudioRecordingDevice, config.AudioPlayoutDevice, config.AudioCodec.ToString(), config.AudioBitrate) == 0); }
/// <summary> /// Updates the positions and rotations of each tracker's parent object according to the replay time. /// </summary> public override void LateUpdate() { if (dynamicCamera == null) { dynamicCamera = UnityEngine.Object.FindObjectOfType <DynamicCamera>(); camera = dynamicCamera.GetComponent <UnityEngine.Camera>(); } if (Input.InputControl.GetButtonDown(Controls.Global.GetButtons().cameraToggle)) { dynamicCamera.ToggleCameraState(dynamicCamera.ActiveState); } if (firstFrame) { firstFrame = false; } else if (UnityEngine.Input.GetKeyDown(KeyCode.Space)) { if (UnityEngine.Input.GetKey(KeyCode.LeftControl) || UnityEngine.Input.GetKey(KeyCode.RightControl)) { rewindTime = Tracker.Lifetime; playbackMode = PlaybackMode.Play; } else { switch (playbackMode) { case PlaybackMode.Paused: if (rewindTime == 0f) { rewindTime = Tracker.Lifetime; } playbackMode = PlaybackMode.Play; break; case PlaybackMode.Play: case PlaybackMode.Rewind: playbackMode = PlaybackMode.Paused; break; } } } switch (playbackMode) { case PlaybackMode.Rewind: rewindTime += Time.deltaTime; break; case PlaybackMode.Play: rewindTime -= Time.deltaTime; break; } if (UnityEngine.Input.GetKey(KeyCode.LeftArrow)) { rewindTime += Time.deltaTime * (UnityEngine.Input.GetKey(KeyCode.LeftControl) || UnityEngine.Input.GetKey(KeyCode.RightControl) ? 0.05f : 0.25f); playbackMode = PlaybackMode.Paused; } if (UnityEngine.Input.GetKey(KeyCode.RightArrow)) { rewindTime -= Time.deltaTime * (UnityEngine.Input.GetKey(KeyCode.LeftControl) || UnityEngine.Input.GetKey(KeyCode.RightControl) ? 0.05f : 0.25f); playbackMode = PlaybackMode.Paused; } if (rewindTime < 0.0f) { rewindTime = 0.0f; playbackMode = PlaybackMode.Paused; } else if (rewindTime > Tracker.Lifetime) { rewindTime = Tracker.Lifetime; playbackMode = PlaybackMode.Paused; } foreach (Tracker t in trackers) { float replayTime = RewindFrame; int currentIndex = (int)Math.Floor(replayTime); StateDescriptor lowerState = t.States[currentIndex]; StateDescriptor upperState = currentIndex < t.States.Length - 1 ? t.States[currentIndex + 1] : lowerState; float percent = replayTime - currentIndex; BRigidBody rb = t.GetComponent <BRigidBody>(); if (!rb.GetCollisionObject().IsActive) { rb.GetCollisionObject().Activate(); } rb.SetPosition(BulletSharp.Math.Vector3.Lerp(lowerState.Position, upperState.Position, percent).ToUnity()); rb.SetRotation(BulletSharp.Math.Matrix.Lerp(lowerState.Rotation, upperState.Rotation, percent).GetOrientation().ToUnity()); } }
void Start() { camera = UnityEngine.Camera.main; FPSCamera = GameObject.Find("FPS Camera"); ShowCursor(false); }
// extension methods to Camera public static Vector3f GetTarget(this UnityEngine.Camera c) { CameraTarget t = c.gameObject.GetComponent <CameraTarget>(); return(t.TargetPoint); }
private void Start() { _camera = GetComponent <UnityEngine.Camera>(); AttachToBoard(); _transform = transform; }
// Start is called before the first frame update void Start() { _tooltips = GetComponents <TooltipTrigger>(); _camera = UnityEngine.Camera.main; _isActive = false; }
// Start is called before the first frame update private void Start() { _cam = UnityEngine.Camera.main; _contexts = Contexts.sharedInstance; }
public override void OnEnable() => Component = gameObject.GetComponent <UnityEngine.Camera>();
//helper method: returns position of mouse with z axis private Vector3 GetMouseWorldPositionWithZ(Vector3 screenPosition, UnityEngine.Camera worldCamera) { return(worldCamera.ScreenToWorldPoint(Mouse.current.position.ReadValue())); }
public virtual void Initialize(UnityEngine.Camera uiCamera) { _canvas.worldCamera = uiCamera; }
void Start() { this.cam = this.GetComponent <UnityEngine.Camera>(); this.cam.backgroundColor = this.baseColor; this.StartCoroutine(this.delayedFlash()); }
public void StreamResourcesForBuiltInCamera(UnityEngine.Camera camera) { m_implementation.StreamResourcesForBuiltInCamera(camera); }
protected override void HandleInput(float magnitude, Vector2 normalised, Vector2 radius, UnityEngine.Camera cam) { if (magnitude > moveThreshold) { Vector2 difference = normalised * (magnitude - moveThreshold) * radius; background.anchoredPosition += difference; } base.HandleInput(magnitude, normalised, radius, cam); }
void Start() { cam = UnityEngine.Camera.main; Target = GenerateTarget(); }
/// <summary> /// Sets the camera that is then controlled by the Wrld map. /// </summary> /// <param name="camera">A Unity camera that can provide the frustum for streaming and is controlled by the Wrld map</param> public void SetControlledCamera(UnityEngine.Camera camera) { m_controlledCamera = camera; }
void Start() { parentCamera = GetComponentInParent <UnityEngine.Camera>(); }
protected override void MapObjects() { //Main Camera GameObject gameObject12566 = new GameObject(); SetObject(12566, gameObject12566); Transform transform12572 = gameObject12566.transform; SetObject(12572, transform12572); UnityEngine.Camera component12570 = gameObject12566.AddComponent <UnityEngine.Camera>(); SetObject(12570, component12570); UnityEngine.AudioListener component12568 = gameObject12566.AddComponent <UnityEngine.AudioListener>(); SetObject(12568, component12568); //Directional Light GameObject gameObject12560 = new GameObject(); SetObject(12560, gameObject12560); Transform transform12564 = gameObject12560.transform; SetObject(12564, transform12564); UnityEngine.Light component12562 = gameObject12560.AddComponent <UnityEngine.Light>(); SetObject(12562, component12562); //deathToAmeri ca GameObject gameObject12556 = new GameObject(); SetObject(12556, gameObject12556); Transform transform12558 = gameObject12556.transform; SetObject(12558, transform12558); //blep GameObject gameObject12536 = new GameObject(); SetObject(12536, gameObject12536); Transform transform12538 = gameObject12536.transform; SetObject(12538, transform12538); //GameObject GameObject gameObject12540 = new GameObject(); SetObject(12540, gameObject12540); Transform transform12542 = gameObject12540.transform; SetObject(12542, transform12542); NewBehaviourScript1 component12544 = gameObject12540.AddComponent <NewBehaviourScript1>(); SetObject(12544, component12544); //GameObject (1) GameObject gameObject12552 = new GameObject(); SetObject(12552, gameObject12552); Transform transform12554 = gameObject12552.transform; SetObject(12554, transform12554); //Audio Source GameObject gameObject12546 = new GameObject(); SetObject(12546, gameObject12546); Transform transform12548 = gameObject12546.transform; SetObject(12548, transform12548); UnityEngine.AudioSource component12550 = gameObject12546.AddComponent <UnityEngine.AudioSource>(); SetObject(12550, component12550); //DefaultMcGee GameObject gameObject_6870 = new GameObject(); SetObject(-6870, gameObject_6870); Transform transform_6872 = gameObject_6870.transform; SetObject(-6872, transform_6872); }
protected void Start() { cameraTracker = (ICameraTracker)GetComponent(typeof(ICameraTracker)); uCamera = targetCamera; AutoResize(); }
private void TransitionStarted(CameraApi controller, UnityEngine.Camera camera) { IsTransitioning = true; }
private void TransitionEnded(CameraApi controller, UnityEngine.Camera camera) { IsTransitioning = false; }
void DrawFocalLengthControl(Rect rect, SerializedProperty property, GUIContent label) { const float hSpace = 2; var FOVProperty = property.FindPropertyRelative(() => m_LensSettingsDef.FieldOfView); float dropdownWidth = (rect.width - EditorGUIUtility.labelWidth) / 4; rect.width -= dropdownWidth + hSpace; float f = CameraExtensions.FieldOfViewToFocalLength(FOVProperty.floatValue, SensorSize.y); EditorGUI.BeginProperty(rect, label, FOVProperty); f = EditorGUI.FloatField(rect, label, f); f = CameraExtensions.FocalLengthToFieldOfView(Mathf.Max(f, 0.0001f), SensorSize.y); if (!Mathf.Approximately(FOVProperty.floatValue, f)) { FOVProperty.floatValue = Mathf.Clamp(f, 1, 179); } EditorGUI.EndProperty(); rect.x += rect.width + hSpace; rect.width = dropdownWidth; #if CINEMACHINE_HDRP CinemachineLensPresets presets = CinemachineLensPresets.InstanceIfExists; int preset = -1; if (presets != null) { var focalLength = CameraExtensions.FieldOfViewToFocalLength(FOVProperty.floatValue, SensorSize.y); var aperture = property.FindPropertyRelative(() => m_LensSettingsDef.Aperture).floatValue; var iso = property.FindPropertyRelative(() => m_LensSettingsDef.Iso).intValue; var shutterSpeed = property.FindPropertyRelative(() => m_LensSettingsDef.ShutterSpeed).floatValue; var bladeCount = property.FindPropertyRelative(() => m_LensSettingsDef.BladeCount).intValue; var curvature = property.FindPropertyRelative(() => m_LensSettingsDef.Curvature).vector2Value; var barrelClipping = property.FindPropertyRelative(() => m_LensSettingsDef.BarrelClipping).floatValue; var anamprphism = property.FindPropertyRelative(() => m_LensSettingsDef.Anamorphism).floatValue; var lensShift = property.FindPropertyRelative(() => m_LensSettingsDef.LensShift).vector2Value; preset = presets.GetMatchingPhysicalPreset( focalLength, iso, shutterSpeed, aperture, bladeCount, curvature, barrelClipping, anamprphism, lensShift); } rect.x -= ExtraSpaceHackWTF(); rect.width += ExtraSpaceHackWTF(); int selection = EditorGUI.Popup(rect, GUIContent.none, preset, m_PhysicalPresetOptions); if (selection == m_PhysicalPresetOptions.Length - 1 && CinemachineLensPresets.Instance != null) { Selection.activeObject = presets = CinemachineLensPresets.Instance; } else if (selection >= 0 && selection < m_PhysicalPresetOptions.Length - 1) { var v = presets.m_PhysicalPresets[selection]; FOVProperty.floatValue = CameraExtensions.FocalLengthToFieldOfView(v.m_FocalLength, SensorSize.y); property.FindPropertyRelative(() => m_LensSettingsDef.Aperture).floatValue = v.Aperture; property.FindPropertyRelative(() => m_LensSettingsDef.Iso).intValue = v.Iso; property.FindPropertyRelative(() => m_LensSettingsDef.ShutterSpeed).floatValue = v.ShutterSpeed; property.FindPropertyRelative(() => m_LensSettingsDef.BladeCount).intValue = v.BladeCount; property.FindPropertyRelative(() => m_LensSettingsDef.Curvature).vector2Value = v.Curvature; property.FindPropertyRelative(() => m_LensSettingsDef.BarrelClipping).floatValue = v.BarrelClipping; property.FindPropertyRelative(() => m_LensSettingsDef.Anamorphism).floatValue = v.Anamorphism; property.FindPropertyRelative(() => m_LensSettingsDef.LensShift).vector2Value = v.LensShift; property.serializedObject.ApplyModifiedProperties(); } #else CinemachineLensPresets presets = CinemachineLensPresets.InstanceIfExists; int preset = (presets == null) ? -1 : presets.GetMatchingPhysicalPreset( CameraExtensions.FieldOfViewToFocalLength(FOVProperty.floatValue, SensorSize.y)); rect.x -= ExtraSpaceHackWTF(); rect.width += ExtraSpaceHackWTF(); int selection = EditorGUI.Popup(rect, GUIContent.none, preset, m_PhysicalPresetOptions); if (selection == m_PhysicalPresetOptions.Length - 1 && CinemachineLensPresets.Instance != null) { Selection.activeObject = presets = CinemachineLensPresets.Instance; } else if (selection >= 0 && selection < m_PhysicalPresetOptions.Length - 1) { FOVProperty.floatValue = CameraExtensions.FocalLengthToFieldOfView( presets.m_PhysicalPresets[selection].m_FocalLength, SensorSize.y); property.serializedObject.ApplyModifiedProperties(); } #endif }
/// <summary> /// Credits: http://wiki.unity3d.com/index.php?title=IsVisibleFrom /// </summary> public static bool IsVisibleFrom(this Renderer renderer, UnityEngine.Camera camera) { Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera); return(GeometryUtility.TestPlanesAABB(planes, renderer.bounds)); }
public static void TickBullets(World model) { foreach (var bullet in model.bullets.Values) { bullet.dir += model.wind; bullet.pos += bullet.dir * bullet.speed; UnityEngine.Camera cam = UnityEngine.Camera.main; UnityEngine.Vector2 bulletViewportPos = cam.WorldToViewportPoint(bullet.pos.Vector3()); UnityEngine.Vector3 bulletWorldPos = bullet.pos.Vector3(); if (bulletViewportPos.x < 0 || bulletViewportPos.x > 1) { bullet.dir = new Position(-bullet.dir.x, bullet.dir.y).Normalize(); bullet.pos = new Position( cam.ViewportToWorldPoint( new UnityEngine.Vector2(UnityEngine.Mathf.Clamp01(bulletViewportPos.x), bulletViewportPos.y) ) ); bullet.ricochetLifeHits--; AudioController.Instance.PlaySound(AudioController.Sound.Ricoshet); } if (bulletViewportPos.y < 0 || bulletViewportPos.y > 1) { bullet.dir = new Position(bullet.dir.x, -bullet.dir.y).Normalize(); bullet.pos = new Position( cam.ViewportToWorldPoint( new UnityEngine.Vector2(bulletViewportPos.x, UnityEngine.Mathf.Clamp01(bulletViewportPos.y)) ) ); bullet.ricochetLifeHits--; AudioController.Instance.PlaySound(AudioController.Sound.Ricoshet); } foreach (var bandit in model.bandits.Values) { Circle bulletCircle = CollisionService.CreateCircle(bullet.pos, bullet.dir * bullet.radius, bullet.radius); Circle banditCircle = CollisionService.CreateCircle(bandit.pos, new Position(), bandit.radius); Position hitPoint; if (CollisionService.DynamicToStaticCircleCollision(bulletCircle, banditCircle, out hitPoint)) { model.gizmos.Add(hitPoint); Position delta = hitPoint - bandit.pos; Position normal = delta.Normalize(); Position pushDir = (bullet.dir * 0.5f + normal * 0.75f).Normalize(); bullet.pos = hitPoint; bullet.dir = pushDir; bullet.ricochetLifeHits--; bullet.hits++; bandit.pos += pushDir * -2f; bandit.hp--; if (bandit.hp <= 0) { bandit.isActive = false; } else if (bandit.hp > 0) { model.events.Enqueue(new BanditDamagedEvent(bandit.id)); } } } if (bullet.ricochetLifeHits <= 0) { bullet.isActive = false; } } }
// Use this for initialization void Start() { camTrans = this.transform; camSize = GetComponent <Camera>(); }
public void StreamResourcesForCamera(UnityEngine.Camera zeroBasedCameraECEF, DoubleVector3 cameraOriginECEF, DoubleVector3 interestPointECEF) { m_streamingUpdater.Update(zeroBasedCameraECEF, cameraOriginECEF, interestPointECEF); }
public override bool Raycast(UnityEngine.Vector2 sp, UnityEngine.Camera eventCamera) { return(raycastTarget); }
/// <summary> /// Gets the Mouse Position with Z Axis /// </summary> /// <param name="screenPosition"> The Current position of the player within screen-context</param> /// <param name="worldCamera">The WorldView Camera</param> /// <returns>A Vector3 With the relative mouse position</returns> public Vector3 GetMouseWorldPositionWithZ(Vector3 screenPosition, UnityEngine.Camera worldCamera) { var mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 1.0f); return(worldCamera.ScreenToWorldPoint(mousePos)); }
void Start() { this.tr = this.transform; this.cam = this.GetComponent <UnityEngine.Camera>(); this.Initialize(); }
void Reset() { camera = GetComponent <UnityEngine.Camera>(); }
public static bool IsObjectVisible(this UnityEngine.Camera @this, Renderer renderer) { return(GeometryUtility.TestPlanesAABB(GeometryUtility.CalculateFrustumPlanes(@this), renderer.bounds)); }