private void OnKeyboardCanceled() { if (keyboard != null) { keyboard.active = false; } currentInputing = Inputing.None; }
void OnGUI() { GUI.DrawTextureWithTexCoords(backgroundRect, FresviiGUIColorPalette.Palette, textureCoordsBackground); GUI.depth = GuiDepth; // Background Mat GUI.DrawTextureWithTexCoords(new Rect(Position.x, Position.y, Screen.width, Screen.height), palette, texcoodsBg); if (keyboard != null) { if (keyboard.active) { if (currentInputing == Inputing.UserName) inputUsername = keyboard.text; else if (currentInputing == Inputing.Description) inputDescription = keyboard.text; } else { currentInputing = Inputing.None; } } else { currentInputing = Inputing.None; } GUI.BeginGroup(scrollViewRect); // User Image Rect userImagePosition = new Rect(Screen.width * 0.5f - profileImageSize.x * 0.5f, hMargin, profileImageSize.x, profileImageSize.y); // User Image GUI.DrawTexture(userImagePosition, (loadedUserIcon == null) ? userProfileImage : loadedUserIcon, ScaleMode.ScaleAndCrop); Color tmp = GUI.color; GUI.color = bgColor; GUI.DrawTexture(userImagePosition, textureUserProfileMask, ScaleMode.ScaleToFit); GUI.color = tmp; GUI.DrawTexture(userImagePosition, textureMyProfileCircle); Event e = Event.current; if (e.type == EventType.MouseDown && userImagePosition.Contains(e.mousePosition)) { Fresvii.AppSteroid.Util.ImagePicker.Show(this, Fresvii.AppSteroid.Util.ImagePicker.Type.Gallery, delegate(Texture2D _loadedTexture){ loadedTexture = _loadedTexture; if (loadedTexture != null) { if (loadedTexture.width > profileImageMaxSize.x || loadedTexture.height > profileImageMaxSize.y) { if (loadedUserIcon != null) { Destroy(loadedUserIcon); } Texture2D shrinkedTexture = new Texture2D(128, 128); shrinkedTexture.SetPixels32(Fresvii.AppSteroid.Util.ScaleUnityTexture.ScaleAndSquareCropLnaczos(loadedTexture.GetPixels32(), loadedTexture.width, loadedTexture.height, 128)); shrinkedTexture.Apply(); //loadedUserIcon = TextureLoader.LoadIntoTextureAlpha(shrinkedTexture, textureMyProfileMask); //Destroy(shrinkedTexture); loadedUserIcon = shrinkedTexture; Debug.Log("shrink " + shrinkedTexture == null); } else { Debug.Log("not shrink " + loadedTexture == null); loadedUserIcon = loadedTexture; } } }); } float vPos = userImagePosition.y + userImagePosition.height; //---- username vPos += hMargin; // Username text field Rect userNameTextFieldRect = new Rect(sideMargin, vPos, baseRect.width - 2f * sideMargin, labelHeight); if (GUI.Button(userNameTextFieldRect, "", GUIStyle.none) && currentInputing == Inputing.None) { if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { popUpShield.Enable(OnKeyboardCanceled); currentInputing = Inputing.UserName; keyboard = TouchScreenKeyboard.Open(inputUsername, TouchScreenKeyboardType.Default, false, false, false, false); } } Rect textFieldUsernameRect = userNameTextFieldRect; FresviiGUIUtility.DrawButtonFrame(userNameTextFieldRect, textFiled, scaleFactor); textFieldUsernameRect.x += guiStyleTextFiled.padding.left; textFieldUsernameRect.width -= 2f * guiStyleTextFiled.padding.left; GUI.Label(textFieldUsernameRect, inputUsername, guiStyleLabelUserName); vPos += textFieldUsernameRect.height + hMargin; //----description Rect descriptionTextFieldRect = new Rect(sideMargin, vPos, baseRect.width - 2f * sideMargin, baseRect.height - vPos - hMargin); descriptionTextFieldRect.height = (Screen.width > Screen.height) ? baseRect.height - vPos - hMargin : baseRect.height * 0.336f; if (GUI.Button(descriptionTextFieldRect, "", GUIStyle.none) && currentInputing == Inputing.None) { if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { currentInputing = Inputing.Description; popUpShield.Enable(OnKeyboardCanceled); keyboard = TouchScreenKeyboard.Open(inputDescription, TouchScreenKeyboardType.Default, false, true, false, false); } } FresviiGUIUtility.DrawButtonFrame(descriptionTextFieldRect, textFiled, scaleFactor); descriptionTextFieldRect.x += guiStyleTextFiled.padding.left; descriptionTextFieldRect.width -= 2f * guiStyleTextFiled.padding.left; string text = (string.IsNullOrEmpty(inputDescription) && currentInputing != Inputing.Description) ? FresviiGUIText.Get("Description") : inputDescription; GUI.Label(descriptionTextFieldRect, text, guiStyleLabelUserDescription); GUI.EndGroup(); }