public override void OnInspectorGUI() { EditorGUILayout.BeginVertical(); pp.portalActive = EditorGUILayout.Toggle(new GUIContent("Active Portal"), pp.portalActive); pp.portalType = (PlatformPortal.PlatformPortalType)EditorGUILayout.EnumPopup(new GUIContent("Portal Type"), pp.portalType); if (pp.portalType == PlatformPortal.PlatformPortalType.Exit) { ConnectPortal = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Destination Portal"), ConnectPortal, typeof(GameObject), true); if (ConnectPortal == null || pp.connectedPortal.GetComponent <PlatformPortal>() == null) { //display error message; } } else { GUIContent connectedPortalName = new GUIContent("Previous Portal not Set"); GUIContent previousPlatformIndex = new GUIContent(""); if (ConnectPortal) { connectedPortalName.text = "Platform of Previous Portal: "; PlatformGeneral pre = ConnectPortal.GetComponent <PlatformPortal>().platform; previousPlatformIndex.text = "Row: " + (int)pre.index.x + " Column: " + (int)pre.index.y; } EditorGUILayout.LabelField(connectedPortalName, previousPlatformIndex); } EditorGUILayout.EndVertical(); }
private void checkPlatformUpdate() { //x for positive value, y for negative value. Vector2 ver = new Vector2(float.MinValue, float.MaxValue); Vector2 hor = new Vector2(float.MinValue, float.MaxValue); ps.platforms.Clear(); List <PlatformGeneral> rec = new List <PlatformGeneral>(); foreach (Transform child in ps.transform) { PlatformGeneral c_pg = child.GetComponent <PlatformGeneral>(); rec.Add(c_pg); if (c_pg.platformCenter.x + c_pg.platformSize.x / 2 + c_pg.platformPadding.x > hor.x) { hor.x = c_pg.platformCenter.x + c_pg.platformSize.x / 2 + c_pg.platformPadding.x; } if (c_pg.platformCenter.x - c_pg.platformSize.x / 2 - c_pg.platformPadding.x < hor.y) { hor.y = c_pg.platformCenter.x - c_pg.platformSize.x / 2 - c_pg.platformPadding.x; } if (c_pg.platformCenter.y + c_pg.platformSize.y / 2 + c_pg.platformPadding.y > ver.x) { ver.x = c_pg.platformCenter.y + c_pg.platformSize.y / 2 + c_pg.platformPadding.y; } if (c_pg.platformCenter.y - c_pg.platformSize.y / 2 - c_pg.platformPadding.y < ver.y) { ver.y = c_pg.platformCenter.y - c_pg.platformSize.y / 2 - c_pg.platformPadding.y; } } ps.platformTotalSize.x = hor.x - hor.y; ps.platformTotalSize.y = ver.x - ver.y; ps.platformCenter.x = (hor.x + hor.y) / 2; ps.platformCenter.y = (ver.x + ver.y) / 2; Debug.Log("platformSize: " + ps.platformTotalSize.x + " " + ps.platformTotalSize.y + " " + ps.platformCenter); //reorganize the list record of platforms Comp comp = new Comp(); rec.Sort(comp); foreach (PlatformGeneral pg in rec) { if (pg.index.x > ps.platforms.Count) { List <PlatformGeneral> next_line = new List <PlatformGeneral>() { pg }; ps.platforms.Add(next_line); } else { ps.platforms[(int)pg.index.x - 1].Add(pg); } } Debug.Log("ps has: " + ps.platforms.Count); }