void Start() { PixelPerfectCamera ppc = GetComponent <PixelPerfectCamera>(); ppc.refResolutionX = Screen.width; ppc.refResolutionY = Screen.height; }
// Start is called before the first frame update void Start() { levelState = new LevelState(); cameraRootPosition = CameraTransform.localPosition; pixelPerfectCamera = Camera.GetComponent <PixelPerfectCamera>(); constants.Width = pixelPerfectCamera.refResolutionX / 16; constants.Height = pixelPerfectCamera.refResolutionY / 16; float sizeVertical = Camera.orthographicSize * 2.0f; float sizeHorizontal = sizeVertical * Camera.aspect; // We fill the horizontal (that's an assumption) constants.CelWidth = sizeHorizontal / (float)constants.Width; constants.CelHeight = constants.CelWidth; constants.Parent = LevelParent; // Figure out the top left. Vector2 center = cameraRootPosition; center.x -= (((float)constants.Width * 0.5f) - 0.5f) * constants.CelWidth; center.y += (((float)constants.Height * 0.5f) - 0.5f) * constants.CelHeight; // y is flipped constants.TopLeft = center; ManifestLevel(currentLevel); }
// Use this for initialization void Start() { PixelPerfectCamera ppc = GetComponent <PixelPerfectCamera>(); ppc.cropFrameX = true; ppc.cropFrameY = true; }
//SpringJoint2D spring; void Awake() { pixcam = Camera.main.GetComponent <PixelPerfectCamera>(); if (specialmode) { //spring = transform.Find("Spring").GetComponent<SpringJoint2D>(); //spring.transform.SetParent(null); } shadow.SetActive(false); body = GetComponent <Rigidbody2D>(); sfx = GetComponent <AudioSource>(); col = GetComponent <Collider2D>(); sprite = teleObject.GetComponent <SpriteRenderer>(); em = particles.emission; mouse = GameObject.FindGameObjectWithTag("Player").transform.root.GetComponent <PsychicMouse>(); lastPos = transform.position; oTeleObjectPos = teleObject.localPosition; if (ThrowIndicator) { ThrowIndicator.gameObject.SetActive(false); } }
void Initialize(bool warn) { _canvas = GetComponent <Canvas> (); if (_canvas.renderMode != RenderMode.ScreenSpaceCamera) { if (warn) { Debug.Log("Render mode: " + _canvas.renderMode + " is not supported by CanvasScreenSpaceScaler"); } return; } Camera uiCamera = GetComponent <Canvas> ().worldCamera; _pixelPerfectCamera = uiCamera.GetComponent <PixelPerfectCamera> (); if (_pixelPerfectCamera == null) { if (warn) { Debug.Log("You have to use the PixelPerfectCamera script on the canvas' render camera!"); } return; } _isInitialized = true; AdjustCanvas(); }
// Start is called before the first frame update void Start() { shielddecay = UseShield(); cursorAnim = myCursor.GetComponent <Animator>(); Cursor.visible = false; player = GetComponent <Player>(); normal = LayerMask.NameToLayer("Default"); npc = LayerMask.NameToLayer("Npc"); spring = transform.Find("Spring").GetComponent <SpringJoint2D>(); //spring.transform.SetParent(null); spring.gameObject.SetActive(false); manager = GameObject.FindGameObjectWithTag("GAMEMANAGER").GetComponent <GameManager>(); if (cam) { pixcam = cam.GetComponent <PixelPerfectCamera>(); } SpellusesUI.text = ""; SpellCostUI.text = ""; Punch.onStartWpn = player.DisablePlayer; Punch.onEndWpn = player.EnablePlayerDelayed; //Vector3 mpos = Camera.main.ScreenToWorldPoint(Input.mousePosition); //mpos.z = 0; //ingameMouse = GameObject.Instantiate(mouse, mpos, Quaternion.identity).transform; }
public static void WorldScaleToUICanvas(this Canvas canvas, Canvas uiCanvas, Camera camera) { PixelPerfectCamera perfectCamera = camera.GetComponent <PixelPerfectCamera>(); if (perfectCamera == null) { DebugHelper.LogError("不存在: PixelPerfectCamera"); return; } Vector3 v3 = new Vector3((float)perfectCamera.assetsPPU / (float)perfectCamera.refResolutionX, (float)perfectCamera.assetsPPU / (float)perfectCamera.refResolutionX, 1); canvas.renderMode = RenderMode.WorldSpace; canvas.worldCamera = camera; RectTransform r = canvas.GetComponent <RectTransform>(); Vector3 offScale = uiCanvas.GetComponent <RectTransform>().localScale; if (offScale.x == 0 || offScale.y == 0) { r.localScale = v3; } else { r.localScale = new Vector3(v3.x / offScale.x, v3.y / offScale.y, 1); } }
void FindPixelPerfectCamera() { if (pixelPerfectCamera == null) { pixelPerfectCamera = FindObjectOfType <PixelPerfectCamera>(); } }
void Initialize() { _canvas = GetComponent <Canvas> (); if (_canvas.renderMode != RenderMode.WorldSpace) { Debug.Log("Render mode: " + _canvas.renderMode + " is not supported by CanvasWorldScaler"); return; } if (uiCamera == null) { Debug.Log("You have to assign a UI camera first!"); return; } _pixelPerfectCamera = uiCamera.GetComponent <PixelPerfectCamera> (); if (_pixelPerfectCamera == null) { Debug.Log("You have to use the PixelPerfectCamera script on the assigned UI camera first!"); return; } AdjustCanvas(); }
private void Awake() { _highScoresController = FindObjectOfType <HighScoresController>(); _pixelPerfectCamera = FindObjectOfType <PixelPerfectCamera>(); _spawner = FindObjectOfType <Spawner>(); _timeController = GetComponent <TimeController>(); }
private void Awake() { player = FindObjectOfType <PlayerController>().gameObject; playerMovement = player.GetComponent <MovementManager>(); pixelPerfect = GetComponent <PixelPerfectCamera>(); originalAppu = pixelPerfect.assetsPPU; }
private void Start() { camera = GetComponent <PixelPerfectCamera>(); xStart = transform.position.x; yStart = transform.position.y; }
void Awake() { keyBindings = KeyBindings.GetKeyBindings; ResetCamSize(); cam = Camera.main.GetComponent <PixelPerfectCamera>(); speed = 5f / cam.assetsPPU; }
private GameObject FormatBackgrounds(List <Background> list) { // GameObject backgroundsContainer = // new GameObject("Backgrounds") { tag = TilemapConstants.BACKGROUND_CONTAINER_TAG }; GameObject backgroundCamera = GameObject.FindWithTag(Tags.BACKGROUND_CAMERA_TAG); if (backgroundCamera == null) { Debug.Log("Creating new camera"); backgroundCamera = new GameObject(Tags.BACKGROUND_CAMERA_TAG) { tag = Tags.BACKGROUND_CAMERA_TAG }; backgroundCamera.transform.position = new Vector3(0, 0, -50); backgroundCamera.AddComponent <CameraMovement>(); Camera bgCam = backgroundCamera.TryAddComponent <Camera>(); bgCam.orthographic = true; bgCam.orthographicSize = 7; PixelPerfectCamera ppCam = backgroundCamera.TryAddComponent <PixelPerfectCamera>(); ppCam.InitializeCamera(settings); CreateBackgroundObjects(list, backgroundCamera); } else { backgroundCamera.TryAddComponent <CameraMovement>(); if (overwriteBackgrounds) { backgroundCamera.transform.RemoveAllChildren(); CreateBackgroundObjects(list, backgroundCamera); } } return(backgroundCamera); }
private void Start() { ppc = (FindObjectOfType(typeof(PixelPerfectCamera)) as PixelPerfectCamera); scale = ppc.pixelRatio; OnScaleChanged(scale); }
private void InitializeComponents() { if (mainModel == null) { mainModel = GetComponent <MainModel>(); } if (camera == null) { camera = GetComponent <PixelPerfectCamera>(); } if (gameBoard == null) { gameBoard = GetComponent <IGameBoard>(); } if (dataService == null) { dataService = GetComponent <IDataService>(); } if (inputController == null) { inputController = GetComponent <IInput>(); } if (screensManager == null) { screensManager = GetComponent <IScreensManager>(); } if (gameStatesFactory == null) { gameStatesFactory = GetComponent <IGameStatesFactory>(); } }
private void Awake( ) { PPCamera = GetComponent <PixelPerfectCamera> ( ); #if UNITY_ANDROID || UNITY_IOS Screen.sleepTimeout = SleepTimeout.NeverSleep; #endif }
private void Start() { PM = GameObject.Find("GameManager").GetComponent <PlayerManager>(); PPC = GetComponent <PixelPerfectCamera>(); this.transform.position = new Vector3(GameObject.FindGameObjectWithTag("Player").transform.position.x, GameObject.FindGameObjectWithTag("Player").transform.position.y, -10f); }
UniversalAdditionalCameraData GetCameraData() { PixelPerfectCamera obj = target as PixelPerfectCamera; UniversalAdditionalCameraData cameraData = null; obj?.TryGetComponent(out cameraData); return(cameraData); }
private Vector2 _roomMin; // Bottom Left Corner // Start is called before the first frame update void Start() { _ppc = GetComponent <PixelPerfectCamera>(); _cam = GetComponent <Camera>(); _cameraHalfHeight = _cam.orthographicSize; //Debug.Log("Camera Orthographic: " + _cam.orthographicSize); }
private PixelPerfectCamera campix;// The position the camera is moving towards. // Start is called before the first frame update // Update is called once per frame void Update() { campix = this.GetComponent <PixelPerfectCamera>(); players = GameObject.FindGameObjectsWithTag("Player"); m_DesiredPosition = GetMeanVector(players); this.transform.position = m_DesiredPosition; Zoom(); }
void Start() { Camera = FindObjectOfType <PixelPerfectCamera>(); if (!Camera) { enabled = false; } }
void Awake() { rigidbody2D = GetComponent <Rigidbody2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); pixelPerfectCamera = GameObject.FindObjectOfType <PixelPerfectCamera>(); interactIcon.SetActive(false); colorblindScript = Camera.main.GetComponent <Wilberforce.Colorblind>(); }
private void Awake() { _cam = Camera.main; _pixelCam = _cam.GetComponent <PixelPerfectCamera>(); _resolutionRatio = _pixelCam.refResolutionY / (float)_pixelCam.refResolutionX; _initialPosition = transform.position; _initialRefResolutionX = _pixelCam.refResolutionX; _initialRefResolutionY = _pixelCam.refResolutionY; }
// Start is called before the first frame update void Start() { ppc = Camera.main.GetComponent <PixelPerfectCamera>(); gridComponent = GetComponent <Grid>(); //tilemapComponent = GetComponentInChildren<Tilemap>(); ppc.refResolutionX = gridX * cellSize; ppc.refResolutionY = gridY * cellSize; gridArray = new int[gridX, gridY]; }
private void Awake() { Resolution resolution = Screen.currentResolution; float aspectRatio = (float)resolution.width / resolution.height; PixelPerfectCamera pixelPerfectCamera = GetComponent <PixelPerfectCamera>(); pixelPerfectCamera.refResolutionX = (int)(pixelPerfectCamera.refResolutionY * aspectRatio); }
private void InitializePixelPerfectCamera(Camera camera, Vector2 screenSize) { PixelPerfectCamera pixelPerfect = camera.gameObject.AddComponent <PixelPerfectCamera>(); pixelPerfect.assetsPPU = 1; pixelPerfect.refResolutionX = (int)screenSize.x; pixelPerfect.refResolutionY = (int)screenSize.y; pixelPerfect.upscaleRT = true; }
private Vector2 _roomMin; // Bottom Left Corner void Start() { // Cache components. _ppc = GetComponent <PixelPerfectCamera>(); _cam = GetComponent <Camera>(); // Cache the height and width of the camera. _cameraHalfHeight = _cam.orthographicSize; _cameraHalfWidth = _cameraHalfHeight * _ppc.refResolutionX / _ppc.refResolutionY; }
/* * Start is called before the first frame update. * We use it to gether the required components and set default variables. */ private void Start() { PixelPerfectCamera pixelCam = GetComponent <PixelPerfectCamera>(); if (pixelCam) { pixelCam.refResolutionX = Screen.width; pixelCam.refResolutionY = Screen.height; } }
// Use this for initialization void Start() { pixelPerfectCamera = gameObject.GetComponent <PixelPerfectCamera>(); Debug.Log(Screen.currentResolution.width); Debug.Log(Screen.currentResolution.height); pixelPerfectCamera.refResolutionX = Screen.currentResolution.width / resoultionDivider; pixelPerfectCamera.refResolutionY = Screen.currentResolution.height / resoultionDivider; }
void FindPixelPerfectCamera() { if (pixelPerfectCamera==null) { pixelPerfectCamera=FindObjectOfType<PixelPerfectCamera>(); } }