public void OnClickImageNum(Button btn) { //AudioPlay.main.PlayBtnSound(); Image image = btn.gameObject.GetComponent <Image>(); Text textNum = GetImageText(image); switch (indexInputNum) { case 0: textResult0.text = textNum.text; break; case 1: textResult1.text = textNum.text; break; } indexInputNum++; if (indexInputNum >= totalInputNum) { indexInputNum = 0; //check result int value = Common.String2Int(textResult0.text) * 10 + Common.String2Int(textResult1.text); imageStatus.gameObject.SetActive(true); if (resultValue == value) { //正确,解锁 TextureUtil.UpdateImageTexture(imageStatus, IMAGE_STATUS_OK, false); Invoke("OnResultOk", 0.5f); } else { //错误 TextureUtil.UpdateImageTexture(imageStatus, IMAGE_STATUS_FAIL, false); Invoke("OnResultFail", 1f); } } }
private void OnAutomaticGUI() { float num = 38f; Texture2D texture = this.m_TextureDataProvider.texture; if (texture != null && TextureUtil.IsCompressedTextureFormat(texture.format)) { EditorGUILayout.LabelField(SpriteEditorMenu.s_Styles.automaticSlicingHintLabel, SpriteEditorMenu.s_Styles.notice, new GUILayoutOption[0]); num -= 31f; } this.DoPivotGUI(); EditorGUI.BeginChangeCheck(); int num2 = SpriteEditorMenu.s_Setting.autoSlicingMethod; num2 = EditorGUILayout.Popup(SpriteEditorMenu.s_Styles.methodLabel, num2, SpriteEditorMenu.s_Styles.slicingMethodOptions, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(SpriteEditorMenu.s_Setting, "Change Slicing Method"); SpriteEditorMenu.s_Setting.autoSlicingMethod = num2; } GUILayout.Space(num); }
public override void UpdateItem(List <object> list) { textTitle.text = (index + 1).ToString(); textTitle.fontSize = (int)(height * 0.5f); imageSel.gameObject.SetActive(false); textTitle.gameObject.SetActive(true); TextureUtil.UpdateImageTexture(imageBg, AppCommon.IMAGE_GUANKA_CELL_ITEM_BG_UNLOCK, true); if (index > (GameManager.gameLevelFinish + 1)) { // if (!Application.isEditor) { textTitle.gameObject.SetActive(false); TextureUtil.UpdateImageTexture(imageBg, AppCommon.IMAGE_GUANKA_CELL_ITEM_BG_LOCK, true); } } else if (index == GameManager.gameLevel) { textTitle.gameObject.SetActive(false); TextureUtil.UpdateImageTexture(imageBg, AppCommon.IMAGE_GUANKA_CELL_ITEM_BG_PLAY, true); } LayOut(); }
public Texture2D LoadTexture(string texturePath, Texture2D fallbackTexture) { _pendingTextureUse.Add(texturePath); if (!_textureCache.ContainsKey(texturePath)) { using (var textureStream = this.DataReader.GetFileStream(texturePath)) { if (textureStream == null) { Logger.Warn("Failed to load texture {dataReaderPath}.", this.DataReader.GetPathRepresentation(texturePath)); return(fallbackTexture); } _textureCache.Add(texturePath, TextureUtil.FromStreamPremultiplied(GameService.Graphics.GraphicsDevice, textureStream)); Logger.Debug("Successfully loaded texture {dataReaderPath}.", this.DataReader.GetPathRepresentation(texturePath)); } } return(_textureCache[texturePath]); }
public override string GetInfoString() { string result; if (this.m_PreviewTextures != null && this.m_PreviewPage < this.m_PreviewTextures.Length) { Texture2D texture2D = this.m_PreviewTextures[this.m_PreviewPage]; TextureFormat textureFormat = TextureUtil.GetTextureFormat(texture2D); result = string.Format("{0}x{1} {2}\n{3}", new object[] { texture2D.width, texture2D.height, TextureUtil.GetTextureFormatString(textureFormat), EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySizeLong(texture2D)) }); } else { result = ""; } return(result); }
private void PrintMapInfo() { string text = StringMgr.Instance.Get("MAP_NAME_IS") + " " + StringMgr.Instance.Get("MAP_VERSION") + " " + reg[selected].Alias + reg[selected].Version; LabelUtil.TextOut(crdMapNameText, text, "MiniLabel", new Color(0.79f, 0.76f, 0.67f, 1f), GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); text = StringMgr.Instance.Get("LAST_MODIFIED_DATE") + " " + DateTimeLocal.ToString(reg[selected].RegisteredDate); LabelUtil.TextOut(crdLastDateText, text, "MiniLabel", new Color(0.79f, 0.76f, 0.67f, 1f), GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); text = StringMgr.Instance.Get("DOWNLOAD_COUNT") + ": " + reg[selected].DownloadCount; LabelUtil.TextOut(crdDnCountText, text, "MiniLabel", new Color(0.79f, 0.76f, 0.67f, 1f), GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); text = StringMgr.Instance.Get("MAP_EVAL") + ": "; LabelUtil.TextOut(crdMapEvalText, text, "MiniLabel", new Color(0.79f, 0.76f, 0.67f, 1f), GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); TextureUtil.DrawTexture(crdStarGrade, texStarGradeBg, ScaleMode.StretchToFill); Vector2 pos = new Vector2(crdStarGrade.x + 80f, crdStarGrade.y - 4f); text = "[ " + reg[selected].GetStarAvgString() + " ]"; LabelUtil.TextOut(pos, text, "MiniLabel", new Color(0.79f, 0.76f, 0.67f, 1f), GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); float num = (float)reg[selected].Likes / 100f; TextureUtil.DrawTexture(new Rect(crdStarGrade.x, crdStarGrade.y, crdStarGrade.width * num, crdStarGrade.height), srcRect: new Rect(0f, 0f, num, 1f), image: texStarGrade); text = StringMgr.Instance.Get("SUPPORT_MODE") + ": "; crdModeTextSize = LabelUtil.TextOut(crdSppModeText, text, "MiniLabel", new Color(0.79f, 0.76f, 0.67f, 1f), GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); }
public override void Start() { // Place the button. GlobalConfig config = GlobalConfig.Instance; Rect rect = new Rect(config.Main.MainMenuButtonX, config.Main.MainMenuButtonY, BUTTON_WIDTH, BUTTON_HEIGHT); Vector2 resolution = UIView.GetAView().GetScreenResolution(); VectorUtil.ClampRectToScreen(ref rect, resolution); absolutePosition = rect.position; // Set the atlas and background/foreground atlas = TextureUtil.GenerateLinearAtlas("TMPE_MainMenuButtonAtlas", TextureResources.MainMenuButtonTexture2D, 6, new string[] { MAIN_MENU_BUTTON_BG_BASE, MAIN_MENU_BUTTON_BG_HOVERED, MAIN_MENU_BUTTON_BG_ACTIVE, MAIN_MENU_BUTTON_FG_BASE, MAIN_MENU_BUTTON_FG_HOVERED, MAIN_MENU_BUTTON_FG_ACTIVE }); UpdateSprites(); // Set the button dimensions. width = BUTTON_WIDTH; height = BUTTON_HEIGHT; // Enable button sounds. playAudioEvents = true; var dragHandler = new GameObject("TMPE_MainButton_DragHandler"); dragHandler.transform.parent = transform; dragHandler.transform.localPosition = Vector3.zero; Drag = dragHandler.AddComponent <UIDragHandle>(); Drag.width = width; Drag.height = height; Drag.enabled = !GlobalConfig.Instance.Main.MainMenuButtonPosLocked; }
private void OnGUI() { if (null != grbLogo) { GUI.skin = GUISkinFinder.Instance.GetGUISkin(); switch (step) { case STEP.FADE_IN: GUI.color = Color.Lerp(new Color(1f, 1f, 1f, 0f), new Color(1f, 1f, 1f, 1f), deltaTime / fadeInTime); break; case STEP.WAIT: GUI.color = new Color(1f, 1f, 1f, 1f); break; case STEP.FADE_OUT: GUI.color = Color.Lerp(new Color(1f, 1f, 1f, 1f), new Color(1f, 1f, 1f, 0f), deltaTime / fadeOutTime); break; } TextureUtil.DrawTexture(new Rect((float)((Screen.width - grbLogo.width) / 2), (float)((Screen.height - grbLogo.height) / 2), (float)grbLogo.width, (float)grbLogo.height), grbLogo); } }
public Texture2D getResultTexture() { Color32[] resultColors; if (frontLayerNull) { resultColors = _actualColors; } else { resultColors = TextureUtil.mergetTextureAbovePixelArray(frontLayer.getTexture(), _actualColors); } Texture2D result = new Texture2D((int)this.size.x, (int)this.size.y, TextureFormat.ARGB32, false); result.SetPixels32(resultColors); result.Apply(); resultColors = null; return(result); }
/// <summary> /// Awake is called when the script instance is being loaded. /// </summary> void Awake() { indexInputNum = 0; totalInputNum = 2; randomNum0 = Random.Range(3, 10); randomNum1 = Random.Range(4, 10); resultValue = randomNum0 * randomNum1; imageStatus.gameObject.SetActive(false); textMath.text = randomNum0.ToString() + "X" + randomNum1.ToString() + "="; textResult0 = GetImageText(imageResult0); textResult1 = GetImageText(imageResult1); TextureUtil.UpdateImageTexture(imageLogoBg, IMAGE_LOGO_BG, false); TextureUtil.UpdateImageTexture(imageLogo, IMAGE_LOGO, true); TextureUtil.UpdateImageTexture(imageNumBoardBg, IMAGE_NUM_BOARD_BG, false); TextureUtil.UpdateImageTexture(imageResult0, IMAGE_NUM_RESULT_BG, false); TextureUtil.UpdateImageTexture(imageResult1, IMAGE_NUM_RESULT_BG, false); TextureUtil.UpdateImageTexture(imageStatus, IMAGE_STATUS_OK, false); TextureUtil.UpdateImageTexture(imageNum0, IMAGE_NUM_BG, false); TextureUtil.UpdateImageTexture(imageNum1, IMAGE_NUM_BG, false); TextureUtil.UpdateImageTexture(imageNum2, IMAGE_NUM_BG, false); TextureUtil.UpdateImageTexture(imageNum3, IMAGE_NUM_BG, false); TextureUtil.UpdateImageTexture(imageNum4, IMAGE_NUM_BG, false); TextureUtil.UpdateImageTexture(imageNum5, IMAGE_NUM_BG, false); TextureUtil.UpdateImageTexture(imageNum6, IMAGE_NUM_BG, false); TextureUtil.UpdateImageTexture(imageNum7, IMAGE_NUM_BG, false); TextureUtil.UpdateImageTexture(imageNum8, IMAGE_NUM_BG, false); TextureUtil.UpdateImageTexture(imageNum9, IMAGE_NUM_BG, false); Button[] btnList = objNumBoard.GetComponentsInChildren <Button>(); foreach (Button btn in btnList) { // btn.onClick.AddListener(() => OnClickImageNum(btn)); } }
internal static void Init() { ButtonTex = TextureUtil.CreateTexture("Assets/Textures/Button.png", TextureUtil.TextureInterp.Nearest); LabelTex = TextureUtil.CreateTexture("Assets/Textures/Label.png", TextureUtil.TextureInterp.Nearest); TextboxTex = TextureUtil.CreateTexture("Assets/Textures/Textbox.png", TextureUtil.TextureInterp.Nearest); GameBackgroundTex = TextureUtil.CreateTexture("Assets/Textures/GameBackground.png", TextureUtil.TextureInterp.Linear); DesertBackgroundTex = TextureUtil.CreateTexture("Assets/Textures/DesertBackground.png", TextureUtil.TextureInterp.Linear); NightBackgroundTex = TextureUtil.CreateTexture("Assets/Textures/NightBackground.png", TextureUtil.TextureInterp.Linear); TitleBackgroundTex = TextureUtil.CreateTexture("Assets/Textures/TitleScreenBackground2.png", TextureUtil.TextureInterp.Linear); FontCenturyGothicTex = TextureUtil.CreateTexture("Assets/Fonts/CenturyGothic.png", TextureUtil.TextureInterp.Nearest); FontChillerTex = TextureUtil.CreateTexture("Assets/Fonts/Chiller.png", TextureUtil.TextureInterp.Nearest); FontDialogInputTex = TextureUtil.CreateTexture("Assets/Fonts/DialogInput.png", TextureUtil.TextureInterp.Nearest); FontLucidaConsoleTex = TextureUtil.CreateTexture("Assets/Fonts/LucidaConsole.png", TextureUtil.TextureInterp.Nearest); ItemTexture = TextureUtil.CreateTexture("Assets/Textures/ItemTextures.png", TextureUtil.TextureInterp.Nearest); TerrainTexture = TextureUtil.CreateTexture("Assets/Textures/TerrainTextures.png", TextureUtil.TextureInterp.Nearest); EntityTexture = TextureUtil.CreateTexture("Assets/Textures/EntityTextures.png", TextureUtil.TextureInterp.Nearest); HealthbarTexture = TextureUtil.CreateTexture("Assets/Textures/Healthbar.png", TextureUtil.TextureInterp.Nearest); }
public Texture2D TryGetTexture(string name, int type) { if (name == null) { return(null); } if (dicTex.TryGetValue(name, out Texture2D value)) { return(value); } Sprite spData = null; switch (type) { case 1: spData = GetTrunkSpriteByName(name); break; case 2: spData = GetHairSpriteByName(name); break; case 3: spData = GetEyeSpriteByName(name); break; case 4: spData = GetMouthSpriteByName(name); break; } if (spData == null) { return(null); } value = TextureUtil.SpriteToTexture2D(spData); dicTex.Add(name, value); return(value); }
public void OnGUI() { if (!this.ValidateProGUI()) { return; } if (!this.ValidateIsPackingEnabled()) { return; } Matrix4x4 matrix = Handles.matrix; base.InitStyles(); this.RefreshState(); Rect rect = EditorGUILayout.BeginHorizontal(GUIContent.none, EditorStyles.toolbar, new GUILayoutOption[0]); this.DoToolbarGUI(); GUILayout.FlexibleSpace(); bool enabled = GUI.enabled; GUI.enabled = (this.m_AtlasNames.Length > 0); base.DoAlphaZoomToolbarGUI(); GUI.enabled = enabled; EditorGUILayout.EndHorizontal(); if (this.m_Texture == null) { return; } EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); this.m_TextureViewRect = new Rect(0f, rect.yMax, base.position.width - 16f, base.position.height - 16f - rect.height); GUILayout.FlexibleSpace(); base.DoTextureGUI(); string text = string.Format("{1}x{2}, {0}", TextureUtil.GetTextureFormatString(this.m_Texture.format), this.m_Texture.width, this.m_Texture.height); EditorGUI.DropShadowLabel(new Rect(this.m_TextureViewRect.x, this.m_TextureViewRect.y + 10f, this.m_TextureViewRect.width, 20f), text); EditorGUILayout.EndHorizontal(); Handles.matrix = matrix; }
private void OnGUI() { if (MyInfoManager.Instance.isGuiOn) { GUISkin skin = GUI.skin; GUI.skin = GUISkinFinder.Instance.GetGUISkin(); GUI.depth = (int)guiDepth; GUI.enabled = !DialogManager.Instance.IsModal; if (show && killInfo != null) { GameObject gameObject = BrickManManager.Instance.Get(killInfo.KillerSequence); if (null != gameObject) { Camera camera = null; Camera[] componentsInChildren = gameObject.GetComponentsInChildren <Camera>(); int num = 0; while (camera == null && num < componentsInChildren.Length) { if (componentsInChildren[num].enabled) { camera = componentsInChildren[num]; } num++; } if (null != camera) { GUI.BeginGroup(new Rect(((float)Screen.width - crdFrameSize.width) / 2f, 64f, crdFrameSize.width, crdFrameSize.height)); TextureUtil.DrawTexture(crdPortrait, camera.targetTexture, ScaleMode.StretchToFill, alphaBlend: false); TextureUtil.DrawTexture(crdFrameSize, killerPortraitFrame, ScaleMode.StretchToFill); LabelUtil.TextOut(crdNickname, killInfo.Killer, "Label", killerColor, Color.white, TextAnchor.LowerCenter); GUI.EndGroup(); } } } GUI.enabled = true; GUI.skin = skin; } }
public override void Start() { // Place the button. GlobalConfig config = GlobalConfig.Instance; Vector3 pos = new Vector3(config.MainMenuButtonX, config.MainMenuButtonY); ClampPosToScreen(ref pos); absolutePosition = pos; // Set the atlas and background/foreground atlas = TextureUtil.GenerateLinearAtlas("TMPE_MainMenuButtonAtlas", TrafficLightToolTextureResources.MainMenuButtonTexture2D, 6, new string[] { MAIN_MENU_BUTTON_BG_BASE, MAIN_MENU_BUTTON_BG_HOVERED, MAIN_MENU_BUTTON_BG_ACTIVE, MAIN_MENU_BUTTON_FG_BASE, MAIN_MENU_BUTTON_FG_HOVERED, MAIN_MENU_BUTTON_FG_ACTIVE }); UpdateSprites(); // Set the button dimensions. width = 50; height = 50; // Enable button sounds. playAudioEvents = true; var dragHandler = new GameObject("TMPE_DragHandler"); dragHandler.transform.parent = transform; dragHandler.transform.localPosition = Vector3.zero; var drag = dragHandler.AddComponent <UIDragHandle>(); drag.width = width; drag.height = height; }
void UpdateImage() { if (index < listPic.Count) { string pic = listPic[index]; // Debug.Log("UpdateImage:index=" + index + " listPic.Count=" + listPic.Count + " pic=" + pic); Texture2D tex = TextureCache.main.Load(pic); if (tex == null) { Debug.Log("UpdateImage:index=" + index + " tex=null"); } SpriteRenderer rd = this.gameObject.GetComponent <SpriteRenderer>(); //sprite if ((rd != null) && (tex != null)) { // Debug.Log("UpdateImage:index=" + index + " update sprite"); rd.sprite = TextureUtil.CreateSpriteFromTex(tex); } if ((rd == null) && (tex != null)) { Image image = this.gameObject.GetComponent <Image>(); if (image != null) { //image image.sprite = TextureUtil.CreateSpriteFromTex(tex); } else { //rawimage RawImage rawimage = this.gameObject.GetComponent <RawImage>(); rawimage.texture = tex; } RectTransform rctran = this.gameObject.GetComponent <RectTransform>(); rctran.sizeDelta = new Vector2(tex.width, tex.height); } } }
/// <summary> /// Awake is called when the script instance is being loaded. /// </summary> void Awake() { listItem = new List <object>(); //bg TextureUtil.UpdateImageTexture(imageBg, AppRes.IMAGE_MOREAPP_BG, true); StartParse(); LoadPrefab(); heightCell = 512; audioClipBtn = AudioCache.main.Load(AppCommon.AUDIO_BTN_CLICK); oneCellNum = 1; if (Screen.width > Screen.height) { oneCellNum = 2; } totalItem = 0;//cene.MAX_GUANKA_NUM; if (listItem != null) { totalItem = listItem.Count; } numRows = totalItem / oneCellNum; if (totalItem % oneCellNum != 0) { numRows++; } //.Log("MoreApp Start 1"); tableView.dataSource = this; //Debug.Log("MoreApp Start 2"); { string str = Language.main.GetString(AppString.STR_APPCENTER); textTitle.text = str; textTitle.color = AppRes.colorTitle; } }
public Texture2D Load(string filepath, Material mat) { Texture2D tex = null; string key = filepath; if (dicItemMat.ContainsKey(key)) { tex = dicItemMat[key]; } else { Texture2D texOld = Load(filepath); RenderTexture rtTmp = new RenderTexture(texOld.width, texOld.height, 0); Graphics.Blit(texOld, rtTmp, mat); tex = TextureUtil.RenderTexture2Texture2D(rtTmp); if (tex != null) { dicItemMat.Add(key, tex); } } return(tex); }
void OnWizardCreate() { Color32[] borderColors = sheetObject.persistentBorderLayer.GetPixels32(); Color32[] frontColors = sheetObject.persistentFrontOutline.GetPixels32(); for (int i = 0; i < borderColors.Length; i++) { if (borderColors[i].a != 0 || borderColors[i].r != 0 || borderColors[i].g != 0 || borderColors[i].b != 0) { if (frontColors[i].a == 255) { borderColors[i].a = 255; } else { borderColors[i] = Color.clear; } } } sheetObject.persistentBorderLayer.SetPixels32(borderColors); sheetObject.persistentBorderLayer.Apply(); TextureUtil.updateTextureAsset(sheetObject.persistentBorderLayer); }
private static UITextureAtlas GetStylesIcons() { var spriteNames = new string[] { "Hovered", "_", "AddTemplate", "ApplyTemplate", "Copy", "Paste", "SetDefault", "UnsetDefault", }; var atlas = TextureUtil.GetAtlas(nameof(ButtonAtlas)); if (atlas == UIView.GetAView().defaultAtlas) { atlas = TextureUtil.CreateTextureAtlas("Buttons.png", nameof(ButtonAtlas), 25, 25, spriteNames, new RectOffset(2, 2, 2, 2)); } return(atlas); }
private void DrawItemIcon(Item item, Rect crdIcon, bool bForceDark) { Color color = GUI.color; if (item.Usage == Item.USAGE.DELETED) { GUI.color = disabledColor; } if (item.IsPremium) { long num = MyInfoManager.Instance.HaveFunction("premium_account"); if (num < 0) { GUI.color = disabledColor; } } if (bForceDark) { GUI.color = Color.black; } TextureUtil.DrawTexture(crdIcon, item.Template.CurIcon(), ScaleMode.ScaleToFit); GUI.color = color; }
private Texture2D GetTexture(string name) { var background = TextureUtil.LoadTextureFromAssembly(name); var logo = TextureUtil.LoadTextureFromAssembly(Style.Type.ToString()); var widthShift = (background.width - logo.width) / 2; var heightShift = (background.height - logo.height) / 2; var sc = (Color)Style.Color.GetStyleIconColor(); for (var i = 0; i < logo.width; i += 1) { for (var j = 0; j < logo.height; j += 1) { var lc = logo.GetPixel(i, j); var bc = background.GetPixel(i + widthShift, j + heightShift); if (lc.a != 0) { var color = new Color(Blend(bc.r, sc.r, lc.a), Blend(bc.g, sc.g, lc.a), Blend(bc.b, sc.b, lc.a), 1); background.SetPixel(i + widthShift, j + heightShift, color); } } }
private void PrintMapInfo(RegMap reg) { Color txtMainColor = GlobalVars.Instance.txtMainColor; LabelUtil.TextOut(crdMapNameLabel, StringMgr.Instance.Get("MAP_NAME_IS") + " " + StringMgr.Instance.Get("MAP_VERSION"), "MiniLabel", txtMainColor, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); LabelUtil.TextOut(crdMapNameVal, reg.Alias + reg.Version, "MiniLabel", Color.white, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); LabelUtil.TextOut(crdLastModifiedLabel, StringMgr.Instance.Get("LAST_MODIFIED_DATE"), "MiniLabel", txtMainColor, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); LabelUtil.TextOut(crdLastModifiedVal, DateTimeLocal.ToString(reg.RegisteredDate), "MiniLabel", Color.white, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); LabelUtil.TextOut(crdDownloadCountLabel, StringMgr.Instance.Get("DOWNLOAD_COUNT"), "MiniLabel", txtMainColor, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); LabelUtil.TextOut(crdDownloadCountVal, reg.DownloadCount.ToString(), "MiniLabel", Color.white, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); LabelUtil.TextOut(crdMapEvalLabel, StringMgr.Instance.Get("MAP_EVAL"), "MiniLabel", txtMainColor, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); TextureUtil.DrawTexture(crdStar, texStarGradeBg, ScaleMode.StretchToFill); string text = "[ " + reg.GetStarAvgString() + " ]"; LabelUtil.TextOut(crdGradeText, text, "MiniLabel", txtMainColor, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); float num = (float)reg.Likes / 100f; Rect position = new Rect(crdStar.x, crdStar.y, crdStar.width * num, crdStar.height); GUI.BeginGroup(position); TextureUtil.DrawTexture(new Rect(0f, 0f, crdStar.width, crdStar.height), texStarGrade); GUI.EndGroup(); LabelUtil.TextOut(crdModeLabel, StringMgr.Instance.Get("SUPPORT_MODE"), "MiniLabel", txtMainColor, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); }
public override void Start() { string[] textureIds = new string[Enum.GetValues(typeof(ButtonMouseState)).Length *(CanActivate() ? 2 : 1) + FunctionNames.Length * 2]; int i = 0; foreach (ButtonMouseState mouseState in EnumUtil.GetValues <ButtonMouseState>()) { if (CanActivate()) { textureIds[i++] = GetButtonBackgroundTextureId(ButtonName, mouseState, true); } textureIds[i++] = GetButtonBackgroundTextureId(ButtonName, mouseState, false); } foreach (string function in FunctionNames) { textureIds[i++] = GetButtonForegroundTextureId(ButtonName, function, false); } foreach (string function in FunctionNames) { textureIds[i++] = GetButtonForegroundTextureId(ButtonName, function, true); } // Set the atlases for background/foreground atlas = TextureUtil.GenerateLinearAtlas("TMPE_" + ButtonName + "Atlas", AtlasTexture, textureIds.Length, textureIds); UpdateProperties(); // Set the button dimensions. width = Width; height = Height; // Enable button sounds. playAudioEvents = true; }
private void OnGUI() { if (!BrickManager.Instance.IsLoaded) { GUISkin skin = GUI.skin; GUI.skin = GUISkinFinder.Instance.GetGUISkin(); GUI.depth = (int)guiDepth; GUI.enabled = !DialogManager.Instance.IsModal; TextureUtil.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), blackOut); if (null != loading) { int width = loading.width; int height = loading.height; if (Screen.width <= 800) { width = Screen.width; } if (Screen.height <= 600) { height = Screen.height; } GUI.BeginGroup(new Rect((float)((Screen.width - width) / 2), (float)((Screen.height - height) / 2), (float)width, (float)height)); TextureUtil.DrawTexture(new Rect(0f, 0f, (float)width, (float)height), loading); Texture2D logo = BuildOption.Instance.Props.logo; if (null != logo) { Vector2 vector = new Vector2((float)width - crdLogoSize.x + crdLogoOffset.x, crdLogoOffset.y); TextureUtil.DrawTexture(new Rect(vector.x, vector.y, crdLogoSize.x, crdLogoSize.y), logo, ScaleMode.StretchToFill); } Vector2 pos = new Vector2((float)(width / 2), (float)(height - 75)); LabelUtil.TextOut(pos, tip, "Label", Color.white, GlobalVars.txtEmptyColor, TextAnchor.UpperCenter, 500f); GUI.EndGroup(); } GUI.enabled = true; GUI.skin = skin; } }
protected Rect DoAlphaZoomToolbarGUI(Rect area) { int mipCount = 1; if (m_Texture != null) { mipCount = Mathf.Max(mipCount, TextureUtil.GetMipmapCount(m_Texture)); } Rect drawArea = new Rect(area.width, 0, 0, area.height); using (new EditorGUI.DisabledScope(mipCount == 1)) { drawArea.width = m_Styles.largeMip.image.width; drawArea.x -= drawArea.width; GUI.Box(drawArea, m_Styles.largeMip, m_Styles.preLabel); drawArea.width = EditorGUI.kSliderMinW; drawArea.x -= drawArea.width; m_MipLevel = Mathf.Round(GUI.HorizontalSlider(drawArea, m_MipLevel, mipCount - 1, 0, m_Styles.preSlider, m_Styles.preSliderThumb)); drawArea.width = m_Styles.smallMip.image.width; drawArea.x -= drawArea.width; GUI.Box(drawArea, m_Styles.smallMip, m_Styles.preLabel); } drawArea.width = EditorGUI.kSliderMinW; drawArea.x -= drawArea.width; m_Zoom = GUI.HorizontalSlider(drawArea, m_Zoom, GetMinZoom(), k_MaxZoom, m_Styles.preSlider, m_Styles.preSliderThumb); drawArea.width = EditorGUI.kObjectFieldMiniThumbnailWidth; drawArea.x -= drawArea.width + EditorGUI.kSpacing; m_ShowAlpha = GUI.Toggle(drawArea, m_ShowAlpha, m_ShowAlpha ? m_Styles.alphaIcon : m_Styles.RGBIcon, "toolbarButton"); // Returns the area that is not used return(new Rect(area.x, area.y, drawArea.x, area.height)); }
private void DoMeleeProperty(MeleeWeapon melee) { if (null == melee) { Debug.LogError("Error, Fail to get MeleeWeapon component from prefab "); } else { float num = melee.AtkPow / maxAtkPow; float num2 = 1f; float num3 = melee.speedFactor / maxMobility; float num4 = num * 100f; float num5 = num2 * 100f; float num6 = num3 * 100f; if (num > 1f) { num = 1f; } if (num3 > 1f) { num3 = 1f; } DoWeaponPropertyBase(); Color color = GUI.color; GUI.color = Color.yellow; TextureUtil.DrawTexture(new Rect(333f,155f,104f * num,12f),gauge,ScaleMode.StretchToFill); TextureUtil.DrawTexture(new Rect(333f,175f,104f * num2,12f),gauge,ScaleMode.StretchToFill); TextureUtil.DrawTexture(new Rect(333f,195f,104f * num3,12f),gauge,ScaleMode.StretchToFill); GUI.color = color; LabelUtil.TextOut(new Vector2(390f,160f),num4.ToString("0.##") + "%","Label",Color.white,GlobalVars.txtEmptyColor,TextAnchor.MiddleCenter); LabelUtil.TextOut(new Vector2(390f,180f),"N/A","Label",Color.white,GlobalVars.txtEmptyColor,TextAnchor.MiddleCenter); LabelUtil.TextOut(new Vector2(390f,200f),num5.ToString("0.##") + "%","Label",Color.white,GlobalVars.txtEmptyColor,TextAnchor.MiddleCenter); LabelUtil.TextOut(new Vector2(390f,220f),"N/A","Label",Color.white,GlobalVars.txtEmptyColor,TextAnchor.MiddleCenter); LabelUtil.TextOut(new Vector2(390f,240f),num6.ToString("0.##") + "%","Label",Color.white,GlobalVars.txtEmptyColor,TextAnchor.MiddleCenter); LabelUtil.TextOut(new Vector2(390f,260f),StringMgr.Instance.Get("INFINITE"),"Label",Color.white,GlobalVars.txtEmptyColor,TextAnchor.MiddleCenter); } }
private void DoPrizes() { TcPrize[] array = prizes.ToArray(); GUI.Box(crdPrizeList, string.Empty, "BoxPopLine"); float num = CalcFlyingOffset(); spPrize = GUI.BeginScrollView(viewRect: new Rect(0f, 0f, crdPrize.x, (float)array.Length * (crdPrize.y + prizeOffset) + num), position: crdPrizeRect, scrollPosition: spPrize); float y = spPrize.y; float num2 = y + crdPrizeRect.height; for (int i = 0; i < array.Length; i++) { Rect position = new Rect(0f, (float)i * (crdPrize.y + prizeOffset) + num, crdPrize.x, crdPrize.y); float y2 = position.y; float num3 = y2 + position.height; if (num3 >= y && y2 <= num2) { if (GUI.Button(position, new GUIContent(array[i].Icon, i.ToString()), "BtnBlue")) { } Color color = GUI.color; GUI.color = GlobalVars.Instance.txtMainColor; Rect position2 = new Rect(position.x + 4f, position.y, position.width - 8f, position.height); GUI.Label(position2, array[i].Name, "MiniLabel"); GUI.color = color; if (i == 0 && array[i].NeedOutline) { GUI.Box(position, string.Empty, "BoxBrickSel"); } if (array[i].IsRareItem) { TextureUtil.DrawTexture(new Rect(position.x + 2f, position.y + position.height - (float)(rareItem.height + 2), (float)rareItem.width, (float)rareItem.height), rareItem, ScaleMode.StretchToFill); } } } GUI.EndScrollView(); }
private static UITextureAtlas GetDirectionIcons() { Log.Debug("BaseEditor.GetDirectionIcons() called"); DirectionSpriteNames = new Dictionary <NetInfo.Direction, string>() { { NetInfo.Direction.None, "DirectionNone" }, { NetInfo.Direction.Forward, "DirectionForward" }, { NetInfo.Direction.Backward, "DirectionBackward" }, { NetInfo.Direction.Both, "DirectionBoth" }, { NetInfo.Direction.Avoid, "DirectionAvoid" }, { NetInfo.Direction.AvoidForward, "DirectionAvoidForward" }, { NetInfo.Direction.AvoidBackward, "DirectionAvoidBackward" }, { NetInfo.Direction.AvoidBoth, "DirectionAvoidBoth" }, }; var atlas = TextureUtil.GetAtlas(nameof(DirectionAtlas)); if (atlas == UIView.GetAView().defaultAtlas) { atlas = TextureUtil.CreateTextureAtlas("directions.png", nameof(DirectionAtlas), 64, 64, DirectionSpriteNames.Values.ToArray()); } return(atlas); }
public override void OnPreviewSettings() { // Do not allow changing of pages when multiple atlases is selected. if (targets.Length == 1 && m_OptionDisplays != null && m_OptionValues != null && m_TotalPages > 1) { m_PreviewPage = EditorGUILayout.IntPopup(m_PreviewPage, m_OptionDisplays, m_OptionValues, styles.preDropDown, GUILayout.MaxWidth(50)); } else { m_PreviewPage = 0; } if (m_PreviewTextures != null) { m_PreviewPage = Mathf.Min(m_PreviewPage, m_PreviewTextures.Length - 1); Texture2D t = m_PreviewTextures[m_PreviewPage]; if (t == null) { return; } if (GraphicsFormatUtility.HasAlphaChannel(t.format) || (m_PreviewAlphaTextures != null && m_PreviewAlphaTextures.Length > 0)) { m_ShowAlpha = GUILayout.Toggle(m_ShowAlpha, m_ShowAlpha ? styles.alphaIcon : styles.RGBIcon, styles.previewButton); } int mipCount = Mathf.Max(1, TextureUtil.GetMipmapCount(t)); if (mipCount > 1) { GUILayout.Box(styles.smallZoom, styles.previewLabel); m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(m_MipLevel, mipCount - 1, 0, styles.previewSlider, styles.previewSliderThumb, GUILayout.MaxWidth(64))); GUILayout.Box(styles.largeZoom, styles.previewLabel); } } }