private void onLoadOver() { setLoading(false); if (_loadTool.getResourceID() == -1) { //TODO:将这里补充正确 // _image.=null; } else { object asset = LoadControl.getResource(_loadTool.getResourceID()); if (asset is Texture2D) { Texture2D tex = (Texture2D)asset; _image.texture = tex; } else { Ctrl.errorLog(new Exception("不支持的图片格式:" + asset)); } if (_autoNativeSize) { _image.SetNativeSize(); } } if (_overFunc != null) { _overFunc(); } }
public void loadSplit(int type, string configName, int key, Action <BaseConfig> overFunc) { int configResourceID = LoadControl.getResourceIDByNameAbs(getSplitConfigPath(configName, key)); LoadControl.loadOne(configResourceID, () => { byte[] bytes = (byte[])LoadControl.getResource(configResourceID); BytesReadStream stream = _tempStream; stream.setBuf(bytes); if (CommonSetting.configNeedCompress) { stream.unCompress(); } if (!stream.checkVersion(ShineGlobal.configVersion)) { Ctrl.errorLog("config结构版本不对"); return; } if (!checkSplitStream(stream)) { return; } BaseConfig bConfig = _useData.readBytesOneSplit(type, stream); overFunc(bConfig); }); }
public BaseConfig getSplitConfigSync(int type, string configName, int key) { int configResourceID = LoadControl.getResourceIDByNameAbs(getSplitConfigPath(configName, key)); byte[] bytes = (byte[])LoadControl.getResource(configResourceID); if (bytes == null) { return(null); } BytesReadStream stream = _tempStream; stream.setBuf(bytes); if (CommonSetting.configNeedCompress) { stream.unCompress(); } if (!stream.checkVersion(ShineGlobal.configVersion)) { Ctrl.errorLog("config结构版本不对"); return(null); } if (!checkSplitStream(stream)) { return(null); } BaseConfig bConfig = _useData.readBytesOneSplit(type, stream); return(bConfig); }
private void onLoadOver() { setLoading(false); if (_loadTool.getResourceID() == -1) { //TODO:将这里补充正确 _image.sprite = null; return; } else { Sprite sprite = null; object asset = LoadControl.getResource(_loadTool.getResourceID()); if (asset is Texture2D) { Texture2D tex = (Texture2D)asset; sprite = Sprite.Create(tex, new Rect(0f, 0f, tex.width, tex.height), new Vector2((float)tex.width / 2, (float)tex.height / 2)); } else if (asset is Sprite) { sprite = (Sprite)asset; } else { Ctrl.errorLog(new Exception("不支持的图片格式:" + asset)); } _image.sprite = sprite; if (_autoNativeSize) { _image.SetNativeSize(); } if (_isAutoNativeSpriteSize) { float imageWidth = _image.sprite.rect.width; float imageHeigh = _image.sprite.rect.height; float scale = Mathf.Min(_spriteWidth / imageWidth, _spriteHeigh / imageHeigh); RectTransform rectTransform = transform.GetComponent <RectTransform>(); rectTransform.sizeDelta = imageWidth * scale * Vector2.right + imageHeigh * scale * Vector2.up; } } if (_overFunc != null) { _overFunc(); } }
/// <summary> /// 刷新语言 /// </summary> public void refreshLanguage() { #if UNITY_EDITOR GameC.app.initConfigForEditor(); #endif //补丁,以后想办法 if (FontConfig.getDic() == null) { Ctrl.print("**********************出现异常情况***************"); return; } //暂时加个补丁 if (_fontId == -1) { _fontId = 1; } //获取字体 string fontSource = FontConfig.getFontSource(_fontId); if (String.IsNullOrEmpty(fontSource)) { return; } if (font != null) { if (fontSource.Contains(this.font.name)) { return; } } Font loadFont = null; if (ShineSetting.isEditor) { #if UNITY_EDITOR if (fontSource.Contains("Arial")) { this.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; } else { this.font = AssetDatabase.LoadAssetAtPath <Font>("Assets/source/" + fontSource); } #endif } else { if (fontSource.Contains("Arial")) { loadFont = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; if (loadFont != null) { this.font = loadFont; } } else { LoadControl.loadOne(fontSource, () => { if (this != null) { loadFont = LoadControl.getResource(fontSource) as Font; if (loadFont != null) { this.font = loadFont; } } }); } } }