-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canvas Rescaler #1781
Merged
Merged
Canvas Rescaler #1781
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8cb63cf
Canvas Rescaler
koosemose 0f870f0
Stylecop
koosemose 4a66d9a
Save Scene Changes
koosemose 0939ebf
DPI- based scaling
koosemose e10bcc1
Merge branch 'master' of https://github.com/TeamPorcupine/ProjectPorc…
koosemose d2358de
UI Scale setting
koosemose 8324e9f
Remove dpi scaling and scale on height rather than width
koosemose f75a84e
Adjust Baseline scale
koosemose 15ac532
Fully change to height based scaling
koosemose 045a1ef
Rescale after applying scale change
koosemose 051071d
Adjust settings slider to .1 steps
koosemose f89f929
workaround for Unity scaling bug
koosemose c0a49ce
Conflict Resolution
koosemose 82d1f6c
Missed UI Element scaling fix
koosemose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#region License | ||
// ==================================================== | ||
// Project Porcupine Copyright(C) 2016 Team Porcupine | ||
// This program comes with ABSOLUTELY NO WARRANTY; This is free software, | ||
// and you are welcome to redistribute it under certain conditions; See | ||
// file LICENSE, which is part of this source code package, for details. | ||
// ==================================================== | ||
#endregion | ||
|
||
using System.Collections; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class UIRescaler : MonoBehaviour | ||
{ | ||
public int lastScreenWidth = 0; | ||
|
||
public void Start() | ||
{ | ||
lastScreenWidth = Screen.width; | ||
StartCoroutine("AdjustScale"); | ||
Debug.LogWarning(lastScreenWidth); | ||
} | ||
|
||
public void Update() | ||
{ | ||
if (lastScreenWidth != Screen.width) | ||
{ | ||
lastScreenWidth = Screen.width; | ||
StartCoroutine("AdjustScale"); | ||
} | ||
} | ||
|
||
private IEnumerator AdjustScale() | ||
{ | ||
this.GetComponent<CanvasScaler>().scaleFactor = Screen.width / 1920f; | ||
yield return null; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a coroutine? This will behave just like a function the way you have implemented it, since nothing happens after or while it yields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason, other than leftovers... it used to do something, but I was tweaking all sorts of things trying to get things to behave how I wanted, and I forgot to uncoroutine it.