Skip to content

Instantly share code, notes, and snippets.

@stopiccot
Created August 28, 2018 12:39
Show Gist options
  • Save stopiccot/eae6aafb24fbfd3264010c33881c6bf3 to your computer and use it in GitHub Desktop.
Save stopiccot/eae6aafb24fbfd3264010c33881c6bf3 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(MoveScreenInDevScene))]
public class MoveScreenInDevSceneInspector : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
int size = 30;
GUILayout.BeginHorizontal();
if (GUILayout.Button("<", GUILayout.Width(size), GUILayout.Height(size))) {
var rt = ((MoveScreenInDevScene)target).GetComponent<RectTransform>();
rt.anchorMin = new Vector2(rt.anchorMin.x - 1.1f, rt.anchorMin.y);
rt.anchorMax = new Vector2(rt.anchorMax.x - 1.1f, rt.anchorMax.y);
}
if (GUILayout.Button("/\\", GUILayout.Width(size), GUILayout.Height(size))) {
var rt = ((MoveScreenInDevScene)target).GetComponent<RectTransform>();
rt.anchorMin = new Vector2(rt.anchorMin.x, rt.anchorMin.y + 1.1f);
rt.anchorMax = new Vector2(rt.anchorMax.x, rt.anchorMax.y + 1.1f);
}
if (GUILayout.Button("\\/", GUILayout.Width(size), GUILayout.Height(size))) {
var rt = ((MoveScreenInDevScene)target).GetComponent<RectTransform>();
rt.anchorMin = new Vector2(rt.anchorMin.x, rt.anchorMin.y - 1.1f);
rt.anchorMax = new Vector2(rt.anchorMax.x, rt.anchorMax.y - 1.1f);
}
if (GUILayout.Button(">", GUILayout.Width(size), GUILayout.Height(size))) {
var rt = ((MoveScreenInDevScene)target).GetComponent<RectTransform>();
rt.anchorMin = new Vector2(rt.anchorMin.x + 1.1f, rt.anchorMin.y);
rt.anchorMax = new Vector2(rt.anchorMax.x + 1.1f, rt.anchorMax.y);
}
GUILayout.EndHorizontal();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment