// Change portrait index after portrait was chosen public void ModalClosed(ModalWindow window) { TexturesListWindow texturesListWindow = window as TexturesListWindow; if (texturesListWindow == null) { return; } if (window.Result == ModalWindowResult.Ok) { _actionOnOk.Invoke(texturesListWindow.ChosenIndex); } }
public static void ShowWindow(List <Texture> textures, Vector2 position, Action <int> actionOnOk) { TexturesListWindowOwner windowOwner = new TexturesListWindowOwner(actionOnOk); TexturesListWindow window = ScriptableObject.CreateInstance(typeof(TexturesListWindow)) as TexturesListWindow; window.Textures = textures; window.owner = windowOwner; window.ShowModalUtility(); float halfWidth = Width / 2; float x = position.x - halfWidth; float y = position.y; Rect rect = new Rect(x, y, 0, 0); window.position = rect; window.ShowAsDropDown(rect, new Vector2(Width, Height)); }