Skip to content

Commit

Permalink
Controllable cleaning and fixed point deletion with right click
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed May 28, 2018
1 parent e49192f commit d9d5071
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Assets/Scenes/Main.unity
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ Prefab:
- target: {fileID: 224261597021104126, guid: 79c2718dd59243e4c90e145349e7dadf,
type: 2}
propertyPath: m_AnchoredPosition.y
value: 0
value: 0.000030517578
objectReference: {fileID: 0}
- target: {fileID: 4679437618935694, guid: 79c2718dd59243e4c90e145349e7dadf, type: 2}
propertyPath: m_LocalEulerAnglesHint.y
Expand Down Expand Up @@ -441,7 +441,9 @@ MonoBehaviour:
TargetIP: 127.0.0.1
TargetPort: 5000
Width: 500
WidthMin: 300
Height: 800
HeightMin: 300
Ratio: 0
NbPoints: 10
PointSize: {x: 20, y: 20}
Expand Down
18 changes: 17 additions & 1 deletion Assets/Scripts/FakePointManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public class FakePointManager : MonoBehaviour {

[Header("Area settings")]
public int Width;
public int WidthMin;
public int Height;
public int HeightMin;
public float Ratio;

[Header("Points settings")]
Expand Down Expand Up @@ -83,6 +85,7 @@ void Update () {
if (CursorPoint != null)
{
NbPoints--;
InstanceNumber--;
SendPersonLeft(InstanciatedPoints[0]);
InstanciatedPoints.Remove(0);
Destroy(CursorPoint);
Expand All @@ -109,7 +112,8 @@ void Update () {
CursorPoint.GetComponent<FakePointBehaviour>().manager = this;

InstanciatedPoints.Add(0, CursorPoint);
NbPoints++; InstanceNumber++;
InstanceNumber++;
NbPoints++;
}
}

Expand Down Expand Up @@ -181,6 +185,18 @@ public void Clear()
InstanciatedPoints.Clear();
}

public void ChangeResolution()
{
var newWidth = Mathf.Clamp(Width, WidthMin, Screen.width);
var newHeight = Mathf.Clamp(Height, HeightMin, Screen.height);
var ratio = Width / Height;

if (Height > Width)
Screen.SetResolution(newWidth, newHeight * ratio, false);
else
Screen.SetResolution(newWidth * ratio, newHeight, false);
}

public void OnMouseDrag()
{
if (CursorPoint == null || !CanMoveCursorPoint) return;
Expand Down
13 changes: 1 addition & 12 deletions Assets/Scripts/FakePointManagerControllable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,6 @@ public override void OnUiValueChanged(string name)
{
base.OnUiValueChanged(name);
manager.PointSize = new Vector2(PointSizeX / Width, PointSizeY / Height);
ChangeResolution();
}

public void ChangeResolution()
{
Screen.SetResolution(Width, Height, false);
float safeWidth = Screen.safeArea.width;
float safeHeight = Screen.safeArea.height;
if (Height > Width)
Screen.SetResolution((int)safeWidth, (int)(safeWidth * ((float)Height / (float)Width)), false);
else
Screen.SetResolution((int)(safeHeight * ((float)Width / (float)Height)), (int)safeHeight, false);
manager.ChangeResolution();
}
}

0 comments on commit d9d5071

Please sign in to comment.