public void SetMainTex(string _file) { if (Object.op_Equality((Object)this.panelComponent, (Object)null)) { return; } if (_file.IsNullOrEmpty()) { this.itemInfo.panel.filePath = string.Empty; this.panelComponent.SetMainTex((Texture2D)null); this.textureMain = (Texture2D)null; } else { this.itemInfo.panel.filePath = _file; string str = UserData.Path + BackgroundList.dirName + "/" + _file; if (!File.Exists(str)) { return; } this.textureMain = PngAssist.LoadTexture(str); this.panelComponent.SetMainTex(this.textureMain); Resources.UnloadUnusedAssets(); } }
IEnumerator LoadButtonsAsync(Transform parent, List <KeyValuePair <DateTime, string> > scenefiles) { string categoryText = category.captionText.text; string sceneFilePath = ""; foreach (var scene in scenefiles) { sceneFilePath = scene.Value; // Mod Orginizer fix if (!File.Exists(sceneFilePath)) { sceneFilePath = ModOrginizerPathFix(sceneFilePath); } LoadingIcon.loadingState[categoryText] = true; //Console.WriteLine("URL 1:" + scene.Value); using (WWW www = new WWW("file:///" + sceneFilePath)) { //Console.WriteLine("URL 2:"+scene.Value); yield return(www); if (!string.IsNullOrEmpty(www.error)) { throw new Exception(www.error); } CreateSceneButton(parent, PngAssist.ChangeTextureFromByte(www.bytes), sceneFilePath); } } LoadingIcon.loadingState[categoryText] = false; }
private void Start() { ObservableExtensions.Subscribe <int>(Observable.Where <int>((IObservable <M0>) this.SelectedID, (Func <M0, bool>)(x => x >= 0 && x < this.lstCoordinates.Count)), (Action <M0>)(x => { for (int index = 0; index < this.lstCoordinates.Count; ++index) { if (this.lstCoordinates[index].id == x) { this.SelectedLabel.set_text(this.lstCoordinates[index].coodeName.get_text()); this.filename = this.lstCoordinates[index].fileName; this.CardImage.set_texture((Texture)PngAssist.ChangeTextureFromByte(this.lstCoordinatesBase[x].pngData == null ? PngFile.LoadPngBytes(this.lstCoordinatesBase[x].FullPath) : this.lstCoordinatesBase[x].pngData, 0, 0, (TextureFormat)5, false)); } } if (!((Component)this.CardImage).get_gameObject().get_activeSelf()) { ((Component)this.CardImage).get_gameObject().SetActive(true); } for (int index = 0; index < this.lstCoordinates.Count; ++index) { if (this.lstCoordinates[index].id != x) { ((Graphic)this.lstCoordinates[index].image).set_color(Color.get_white()); } else { ((Graphic)this.lstCoordinates[index].image).set_color(Define.Get(Colors.Yellow)); } } })); }
public static Texture2D LoadTexture(byte[] bytes) { Texture2D result; using (var memoryStream = new MemoryStream(bytes)) { long num = 0L; PngAssist.CheckPngData(memoryStream, ref num, false); if (num == 0L) { result = null; } else { using (BinaryReader binaryReader = new BinaryReader(memoryStream)) { byte[] data = binaryReader.ReadBytes((int)num); int num2 = 0; int num3 = 0; result = PngAssist.ChangeTextureFromPngByte(data, ref num2, ref num3); } } } return(result); }
public void SetData(int index, GameCoordinateFileInfo info, Action <bool> onClickAction) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type GameCoordinateFileInfoComponent.\u003CSetData\u003Ec__AnonStorey0 dataCAnonStorey0 = new GameCoordinateFileInfoComponent.\u003CSetData\u003Ec__AnonStorey0(); // ISSUE: reference to a compiler-generated field dataCAnonStorey0.onClickAction = onClickAction; // ISSUE: reference to a compiler-generated field dataCAnonStorey0.\u0024this = this; bool active = info != null; GameCoordinateFileInfoComponent.RowInfo row = this._rows[index]; ((Component)row.toggle).get_gameObject().SetActiveIfDifferent(active); ((UnityEventBase)row.toggle.onValueChanged).RemoveAllListeners(); if (!active) { return; } ((UnityEventBase)row.toggle.onValueChanged).RemoveAllListeners(); // ISSUE: method pointer ((UnityEvent <bool>)row.toggle.onValueChanged).AddListener(new UnityAction <bool>((object)dataCAnonStorey0, __methodptr(\u003C\u003Em__0))); row.toggle.SetIsOnWithoutCallback(false); ((Selectable)row.toggle).set_interactable(!info.IsInSaveData); row.imageThumb.set_texture((Texture)PngAssist.ChangeTextureFromByte(info.PngData ?? PngFile.LoadPngBytes(info.FullPath), 0, 0, (TextureFormat)5, false)); row.objSelect.SetActiveIfDifferent(false); // ISSUE: reference to a compiler-generated field dataCAnonStorey0.sel = index; // ISSUE: method pointer row.pointerAction.listActionEnter.Add(new UnityAction((object)dataCAnonStorey0, __methodptr(\u003C\u003Em__1))); // ISSUE: method pointer row.pointerAction.listActionExit.Add(new UnityAction((object)dataCAnonStorey0, __methodptr(\u003C\u003Em__2))); row.info = info; }
public void CreateCoordinateFileBefore() { if (this.customBase.customCtrl.draw3D) { this.custom3DRender.update = false; this.imgDummy.set_texture((Texture)this.custom3DRender.GetRenderTexture()); } else { this.custom2DRender.update = false; this.imgDummy.set_texture((Texture)this.custom2DRender.GetRenderTexture()); } ((Component)((Component)this.imgDummy).get_transform().get_parent()).get_gameObject().SetActiveIfDifferent(true); this.chaCtrl.ChangeSettingMannequin(true); this.customDrawMenu.ChangeClothesStateForCapture(true); this.customBase.saveFrameAssist.ChangeSaveFrameTexture(1, (Texture)PngAssist.LoadTexture2DFromAssetBundle("custom/custom_etc.unity3d", "coordinate_front")); this.backPoseNo = this.customBase.poseNo; if (Object.op_Inequality((Object)null, (Object)this.chaCtrl.animBody)) { AnimatorStateInfo animatorStateInfo = this.chaCtrl.getAnimatorStateInfo(0); this.backPosePos = ((AnimatorStateInfo) ref animatorStateInfo).get_normalizedTime(); this.customBase.animationPos = 0.0f; this.customBase.ChangeAnimationNo(0, true); this.chaCtrl.resetDynamicBoneAll = true; } this.customBase.updateCustomUI = true; for (int slotNo = 0; slotNo < 20; ++slotNo) { this.customBase.ChangeAcsSlotName(slotNo); } this.customBase.SetUpdateToggleSetting(); this.customBase.forceUpdateAcsList = true; }
private static IEnumerator MapSelectMenuScene_Start_Postfix(GameObject nodeFrame, ReactiveProperty <MapInfo.Param> _mapInfo) { StudioSceneFile = null; int i = 0; int childCount = nodeFrame.transform.childCount; GameObject currentFrame = null; foreach (FileInfo fn in from p in new DirectoryInfo(UserData.Create("studio/scene")).GetFiles("*.png") orderby p.CreationTime descending select p) { if (i % childCount == 0) { currentFrame = Instantiate(nodeFrame, nodeFrame.transform.parent, false); currentFrame.SetActive(true); } GameObject gameObject = currentFrame.transform.GetChild(i % childCount).gameObject; i++; gameObject.SetActive(true); Button button = gameObject.GetComponent <Button>(); button.GetComponent <Image>().sprite = PngAssist.LoadSpriteFromFile(fn.FullName); button.onClick.AddListener(() => { var param = new MapInfo.Param(); _mapInfo.Value = param; StudioSceneFile = fn.FullName; //enterMapColor.Value = button; Utils.Sound.Play(SystemSE.sel); }); } yield return(null); }
private void SetPage(int _page) { StudioNode studioNode = (StudioNode)null; if (this.dicPage.TryGetValue(SceneLoadScene.page, out studioNode)) { studioNode.select = false; } _page = Mathf.Clamp(_page, 0, this.pageNum - 1); int num = 12 * _page; for (int index = 0; index < 12; ++index) { int n = num + index; if (!MathfEx.RangeEqualOn <int>(0, n, this.thumbnailNum - 1)) { this.buttonThumbnail[index].interactable = false; } else { this.buttonThumbnail[index].texture = (Texture)PngAssist.LoadTexture(this.listPath[n]); this.buttonThumbnail[index].interactable = true; } } SceneLoadScene.page = _page; if (this.dicPage.TryGetValue(SceneLoadScene.page, out studioNode)) { studioNode.select = true; } Resources.UnloadUnusedAssets(); GC.Collect(); }
public bool Load(string _file) { string str = UserData.Path + BackgroundList.dirName + "/" + _file; if (!File.Exists(str)) { this.isVisible = false; Singleton <Studio.Studio> .Instance.sceneInfo.background = string.Empty; return(false); } Texture texture = (Texture)PngAssist.LoadTexture(str); if (Object.op_Equality((Object)texture, (Object)null)) { this.isVisible = false; return(false); } Material material = ((Renderer)this.meshRenderer).get_material(); material.SetTexture("_MainTex", texture); ((Renderer)this.meshRenderer).set_material(material); this.isVisible = true; Singleton <Studio.Studio> .Instance.sceneInfo.background = _file; Resources.UnloadUnusedAssets(); GC.Collect(); return(true); }
public override void Scene_ImportChara(MsgObject message) { using (var fileStream = new FileStream(message.path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (var binaryReader = new BinaryReader(fileStream)) { long size = 0L; PngAssist.CheckPngData(binaryReader, ref size, true); var version = new Version(binaryReader.ReadString()); var sceneInfo = Studio.Studio.Instance.sceneInfo; var traverse = Traverse.Create(sceneInfo); traverse.Property("dicImport").SetValue(new Dictionary <int, ObjectInfo>()); traverse.Property("dicChangeKey").SetValue(new Dictionary <int, int>()); int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { int value = binaryReader.ReadInt32(); int type = binaryReader.ReadInt32(); if (type == 0) { var objectInfo = new OICharInfo(null, Studio.Studio.GetNewIndex()); objectInfo.Load(binaryReader, version, true, true); sceneInfo.dicObject.Add(objectInfo.dicKey, objectInfo); sceneInfo.dicImport.Add(objectInfo.dicKey, objectInfo); sceneInfo.dicChangeKey.Add(objectInfo.dicKey, value); } else { ObjectInfo objectInfo = null; switch (type) { case 1: objectInfo = new OIItemInfo(-1, Studio.Studio.GetNewIndex()); break; case 2: objectInfo = new OILightInfo(-1, Studio.Studio.GetNewIndex()); break; case 3: objectInfo = new OIFolderInfo(Studio.Studio.GetNewIndex()); break; default: Console.WriteLine($"対象外 : {type}"); break; } objectInfo.Load(binaryReader, version, true, true); } } } } AddObjectAssist.LoadChild(Studio.Studio.Instance.sceneInfo.dicImport, null, null); Studio.Studio.Instance.treeNodeCtrl.RefreshHierachy(); }
private void SetParameter(GameCoordinateFileInfo data, bool fromFolder) { this._objParameterWindow.get_activeSelf(); this._objParameterWindow.SetActiveIfDifferent(true); this._rawImageCoordinateCard.set_texture((Texture)PngAssist.ChangeTextureFromByte(PngFile.LoadPngBytes(data.FullPath), 0, 0, (TextureFormat)5, false)); ((Component)this._buttonInput).get_gameObject().SetActiveIfDifferent(fromFolder); ((Component)this._buttonOutput).get_gameObject().SetActiveIfDifferent(!fromFolder); }
protected override void OnBeforeStart() { ObservableExtensions.Subscribe <bool>((IObservable <M0>) this.OnActiveChangedAsObservable(), (Action <M0>)(active => this.SetActiveControl(active))); // ISSUE: method pointer ((UnityEvent)this._charaButton.get_onClick()).AddListener(new UnityAction((object)this, __methodptr(\u003COnBeforeStart\u003Em__1))); ObservableExtensions.Subscribe <int>((IObservable <M0>) this.OnSelectIDChangedAsObservable(), (Action <M0>)(x => { ((Component)this._selectedImageTransform).get_gameObject().SetActiveIfDifferent(x != 1); if (((Component)this._selectedImageTransform).get_gameObject().get_activeSelf()) { ((Transform)this._selectedImageTransform).set_localPosition(((Transform)this._element).get_localPosition()); } this._objPlayerParameterWindow.SetActiveIfDifferent(true); if (this._info == null) { return; } this._txtPlayerCharaName.set_text(this._info.name); this._riPlayerCard.set_texture((Texture)PngAssist.ChangeTextureFromByte(PngFile.LoadPngBytes(this._info.FullPath), 0, 0, (TextureFormat)5, false)); int languageInt = Singleton <GameSystem> .Instance.languageInt; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(this._info.sex != 0 ? this._localizeFemale[languageInt] : this._localizeMale[languageInt]); if (this._info.sex == 1 && this._info.futanari) { stringBuilder.Append(this._localizeFutanari[languageInt]); } this._txtPlayerSex.set_text(stringBuilder.ToString()); })); this._objPlayerParameterWindow.SetActiveIfDifferent(false); this._txtPlayerCharaName.set_text("NoName"); this._riPlayerCard.set_texture((Texture)null); this._txtPlayerSex.set_text(string.Empty); KeyCodeDownCommand keyCodeDownCommand = new KeyCodeDownCommand() { KeyCode = (KeyCode)324 }; // ISSUE: method pointer keyCodeDownCommand.TriggerEvent.AddListener(new UnityAction((object)this, __methodptr(\u003COnBeforeStart\u003Em__3))); this._keyCommands.Add(keyCodeDownCommand); // ISSUE: method pointer ((UnityEvent)this._closeButton.get_onClick()).AddListener(new UnityAction((object)this, __methodptr(\u003COnBeforeStart\u003Em__4))); Button.ButtonClickedEvent onClick = this._charaCreateButton.get_onClick(); // ISSUE: reference to a compiler-generated field if (PlayerLookEditUI.\u003C\u003Ef__am\u0024cache0 == null) { // ISSUE: reference to a compiler-generated field // ISSUE: method pointer PlayerLookEditUI.\u003C\u003Ef__am\u0024cache0 = new UnityAction((object)null, __methodptr(\u003COnBeforeStart\u003Em__5)); } // ISSUE: reference to a compiler-generated field UnityAction fAmCache0 = PlayerLookEditUI.\u003C\u003Ef__am\u0024cache0; ((UnityEvent)onClick).AddListener(fAmCache0); ((Component)this._selectedImageTransform).get_gameObject().SetActive(false); }
private void LoadCharaImage(int _idx) { if (this.isDelay) { return; } this.imageChara.set_texture((Texture)PngAssist.LoadTexture(this.charaFileSort.cfiList[_idx].file)); ((Graphic)this.imageChara).set_color(Color.get_white()); Resources.UnloadUnusedAssets(); GC.Collect(); }
void PopulateGrid(bool forceUpdate = false) { var cache = cardTypes[currentType].cache; var categoryText = category.captionText.text; if (forceUpdate) { cache.Remove(categoryText); } if (cache.TryGetValue(categoryText, out CachedList cachedList)) { cachedList.list.gameObject.SetActive(true); } else { var scenefiles = (from s in Directory.GetFiles(GetCategoryFolder(), "*.png") select new KeyValuePair <DateTime, string>(File.GetLastWriteTime(s), s)).ToList(); scenefiles.Sort((KeyValuePair <DateTime, string> a, KeyValuePair <DateTime, string> b) => b.Key.CompareTo(a.Key)); var container = UIUtility.CreatePanel("GridContainer", imagelist.content.transform); container.transform.SetRect(0f, 0f, 1f, 1f); container.gameObject.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; var gridlayout = container.gameObject.AddComponent <AutoGridLayout>(); gridlayout.spacing = new Vector2(marginSize, marginSize); gridlayout.m_IsColumn = true; gridlayout.m_Column = cardTypes[currentType].columnCount; gridlayout.aspectRatio = cardTypes[currentType].aspectRatio; StartCoroutine(LoadButtonsAsync(container.transform, scenefiles)); cache.Add(categoryText, new CachedList(container)); } IEnumerator LoadButtonsAsync(Transform parent, List <KeyValuePair <DateTime, string> > scenefiles) { foreach (var scene in scenefiles) { LoadingIcon.loadingState[categoryText] = true; using (WWW www = new WWW("file:///" + scene.Value)) { yield return(www); if (!string.IsNullOrEmpty(www.error)) { throw new Exception(www.error); } CreateSceneButton(parent, PngAssist.ChangeTextureFromByte(www.bytes), scene.Value); } } LoadingIcon.loadingState[categoryText] = false; } }
public bool ChangeSaveFrameBack(byte changeNo, bool listUpdate = true) { if (listUpdate) { string str = "cardframe/Back"; string[] searchPattern = new string[1] { "*.png" }; this.dirFrameBack.lstFile.Clear(); this.dirFrameBack.CreateFolderInfoEx(DefaultData.Path + str, searchPattern, true); this.dirFrameBack.CreateFolderInfoEx(UserData.Path + str, searchPattern, false); this.dirFrameBack.SortName(true); } int fileCount = this.dirFrameBack.GetFileCount(); if (fileCount == 0) { return(false); } int index = this.dirFrameBack.GetIndexFromFileName(this.lastFrameBackName); if (index == -1) { index = 0; } else { switch (changeNo) { case 0: index = (index + 1) % fileCount; break; case 1: index = (index + fileCount - 1) % fileCount; break; } } Texture texture1 = (Texture)PngAssist.LoadTexture(this.dirFrameBack.lstFile[index].FullPath); if (Object.op_Implicit((Object)this.rendBack) && Object.op_Implicit((Object)this.rendBack.get_material())) { Texture texture2 = this.rendBack.get_material().GetTexture(ChaShader.MainTex); if (Object.op_Implicit((Object)texture2)) { Object.Destroy((Object)texture2); } this.rendBack.get_material().SetTexture(ChaShader.MainTex, texture1); } this.lastFrameBackName = this.dirFrameBack.lstFile[index].FileName; return(true); }
public void SetData(int _index, GameCharaFileInfo _info, Action <bool> _onClickAction) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type GameCharaFileInfoComponent.\u003CSetData\u003Ec__AnonStorey0 dataCAnonStorey0 = new GameCharaFileInfoComponent.\u003CSetData\u003Ec__AnonStorey0(); // ISSUE: reference to a compiler-generated field dataCAnonStorey0._onClickAction = _onClickAction; // ISSUE: reference to a compiler-generated field dataCAnonStorey0.\u0024this = this; bool active = _info != null; if (active) { active = _info.FullPath.IsNullOrEmpty() || !_info.FullPath.IsNullOrEmpty() && File.Exists(_info.FullPath) || _info.pngData != null; } ((Component)this.rows[_index].tgl).get_gameObject().SetActiveIfDifferent(active); ((UnityEventBase)this.rows[_index].tgl.onValueChanged).RemoveAllListeners(); if (!active) { return; } ((UnityEventBase)this.rows[_index].tgl.onValueChanged).RemoveAllListeners(); // ISSUE: method pointer ((UnityEvent <bool>) this.rows[_index].tgl.onValueChanged).AddListener(new UnityAction <bool>((object)dataCAnonStorey0, __methodptr(\u003C\u003Em__0))); this.rows[_index].tgl.SetIsOnWithoutCallback(false); ((Selectable)this.rows[_index].tgl).set_interactable(!_info.isInSaveData); this.rows[_index].objEntry.SetActiveIfDifferent(_info.isInSaveData); this.rows[_index].objNurturing.SetActiveIfDifferent(_info.gameRegistration); if (Object.op_Inequality((Object)this.rows[_index].imgThumb.get_texture(), (Object)null) && Object.op_Inequality((Object)this.rows[_index].imgThumb.get_texture(), (Object)this.texEmpty)) { Object.Destroy((Object)this.rows[_index].imgThumb.get_texture()); this.rows[_index].imgThumb.set_texture((Texture)null); } if (_info.pngData != null || !_info.FullPath.IsNullOrEmpty()) { this.rows[_index].imgThumb.set_texture((Texture)PngAssist.ChangeTextureFromByte(_info.pngData ?? PngFile.LoadPngBytes(_info.FullPath), 0, 0, (TextureFormat)5, false)); } else { this.rows[_index].imgThumb.set_texture((Texture)this.texEmpty); } this.rows[_index].objSelect.SetActiveIfDifferent(false); // ISSUE: reference to a compiler-generated field dataCAnonStorey0.sel = _index; // ISSUE: method pointer this.rows[_index].pointerAction.listActionEnter.Add(new UnityAction((object)dataCAnonStorey0, __methodptr(\u003C\u003Em__1))); // ISSUE: method pointer this.rows[_index].pointerAction.listActionExit.Add(new UnityAction((object)dataCAnonStorey0, __methodptr(\u003C\u003Em__2))); this.rows[_index].info = _info; }
private void SetPlayerParameter(GameCharaFileInfo _data) { this.objPlayerParameterWindow.SetActiveIfDifferent(true); this.txtPlayerCharaName.set_text(_data.name); this.riPlayerCard.set_texture((Texture)PngAssist.ChangeTextureFromByte(PngFile.LoadPngBytes(_data.FullPath), 0, 0, (TextureFormat)5, false)); int languageInt = Singleton <GameSystem> .Instance.languageInt; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(_data.sex != 0 ? this.localizeFemale[languageInt] : this.localizeMale[languageInt]); if (_data.sex == 1 && _data.futanari) { stringBuilder.Append(this.localizeFutanari[languageInt]); } this.txtPlayerSex.set_text(stringBuilder.ToString()); }
public bool ChangeSaveFrameFront(byte changeNo, bool listUpdate = true) { if (listUpdate) { string str = "cardframe/Front"; string[] searchPattern = new string[1] { "*.png" }; this.dirFrameFront.lstFile.Clear(); this.dirFrameFront.CreateFolderInfoEx(DefaultData.Path + str, searchPattern, true); this.dirFrameFront.CreateFolderInfoEx(UserData.Path + str, searchPattern, false); this.dirFrameFront.SortName(true); } int fileCount = this.dirFrameFront.GetFileCount(); if (fileCount == 0) { return(false); } int index = this.dirFrameFront.GetIndexFromFileName(this.lastFrameFrontName); if (index == -1) { index = 0; } else { switch (changeNo) { case 0: index = (index + 1) % fileCount; break; case 1: index = (index + fileCount - 1) % fileCount; break; } } Texture texture = (Texture)PngAssist.LoadTexture(this.dirFrameFront.lstFile[index].FullPath); if (Object.op_Implicit((Object)this.riFront.get_texture())) { Object.Destroy((Object)this.riFront.get_texture()); } this.riFront.set_texture(texture); this.lastFrameFrontName = this.dirFrameFront.lstFile[index].FileName; return(true); }
private static bool FreeHScene_SetMapSprite(ref Image ___mapImageNormal, ref Image ___mapImageMasturbation, ref Image ___mapImageLesbian) { if (IsStudio) { return(true); } if (StudioSceneFile == null) { return(true); } ___mapImageNormal.sprite = PngAssist.LoadSpriteFromFile(StudioSceneFile); ___mapImageMasturbation.sprite = PngAssist.LoadSpriteFromFile(StudioSceneFile); ___mapImageLesbian.sprite = PngAssist.LoadSpriteFromFile(StudioSceneFile); return(false); }
public static Texture2D LoadResourceTexture(string resourceName) { try { using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) { byte[] buffer = new byte[16 * 1024]; var pngData = ReadFully(stream); return(PngAssist.ChangeTextureFromByte(pngData)); } } catch (Exception) { Console.WriteLine("Error accessing resources"); throw; } }
public string SetPatternTex(int _idx, int _key) { if (_key <= 0) { this.itemInfo.colors[_idx].pattern.key = _key; this.itemInfo.colors[_idx].pattern.filePath = string.Empty; if (Object.op_Implicit((Object)this.itemComponent)) { this.itemComponent.SetPatternTex(_idx, (Texture2D)null); } this.ReleasePatternTex(_idx); return("なし"); } PatternSelectInfo patternSelectInfo = Singleton <Studio.Studio> .Instance.patternSelectListCtrl.lstSelectInfo.Find((Predicate <PatternSelectInfo>)(p => p.index == _key)); string str1 = "なし"; if (patternSelectInfo != null) { if (patternSelectInfo.assetBundle.IsNullOrEmpty()) { string str2 = UserData.Path + "pattern/" + patternSelectInfo.assetName; if (!File.Exists(str2)) { return("なし"); } this.texturePattern[_idx] = PngAssist.LoadTexture(str2); this.itemInfo.colors[_idx].pattern.key = -1; this.itemInfo.colors[_idx].pattern.filePath = patternSelectInfo.assetName; str1 = patternSelectInfo.assetName; } else { string assetBundleName = patternSelectInfo.assetBundle.Replace("thumb/", string.Empty); string assetName = patternSelectInfo.assetName.Replace("thumb_", string.Empty); this.texturePattern[_idx] = CommonLib.LoadAsset <Texture2D>(assetBundleName, assetName, false, string.Empty); this.itemInfo.colors[_idx].pattern.key = _key; this.itemInfo.colors[_idx].pattern.filePath = string.Empty; str1 = patternSelectInfo.name; } } this.itemComponent.SetPatternTex(_idx, this.texturePattern[_idx]); Resources.UnloadUnusedAssets(); return(str1); }
public static void SavePng( BinaryWriter writer, int capW = 504, int capH = 704, int createW = 252, int createH = 352, float renderRate = 1f, bool drawBackSp = true, bool drawFrontSp = true) { byte[] pngData = (byte[])null; PngAssist.CreatePng(ref pngData, capW, capH, createW, createH, renderRate, drawBackSp, drawFrontSp); if (pngData == null) { return; } writer.Write(pngData); }
public static Texture2D LoadTexture(string _path) { using (FileStream fileStream = new FileStream(_path, FileMode.Open, FileAccess.Read)) { long pngSize = PngFile.GetPngSize((Stream)fileStream); if (pngSize == 0L) { return((Texture2D)null); } using (BinaryReader binaryReader = new BinaryReader((Stream)fileStream)) { byte[] data = binaryReader.ReadBytes((int)pngSize); int width = 0; int height = 0; return(PngAssist.ChangeTextureFromPngByte(data, ref width, ref height, (TextureFormat)5, false)); } } }
private void UpdatePreview(DataType type, string path) { Image imgThumbnail; switch (type) { case DataType.Chara: imgThumbnail = this.selInfoCha.imgThumbnail; break; case DataType.Housing: imgThumbnail = this.selInfoHousing.imgThumbnail; break; default: return; } if (Object.op_Equality((Object)null, (Object)imgThumbnail)) { return; } if (Object.op_Inequality((Object)null, (Object)imgThumbnail.get_sprite())) { if (Object.op_Inequality((Object)null, (Object)imgThumbnail.get_sprite().get_texture())) { Object.Destroy((Object)imgThumbnail.get_sprite().get_texture()); } Object.Destroy((Object)imgThumbnail.get_sprite()); imgThumbnail.set_sprite((Sprite)null); } if (!path.IsNullOrEmpty()) { Sprite sprite = PngAssist.LoadSpriteFromFile(path); if (Object.op_Inequality((Object)null, (Object)sprite)) { imgThumbnail.set_sprite(sprite); } ((Behaviour)imgThumbnail).set_enabled(true); } else { ((Behaviour)imgThumbnail).set_enabled(false); } }
IEnumerator ResaveScene() { if (bSavingInProgress) { yield break; } SaveScene(currentPath, true); bSavingInProgress = true; string file_path = currentPath; // (currentPath updated in onBtnClick event.) Transform curr_btn_trans = optionspanel.transform.parent; // Mod Orginizer fix if (!File.Exists(file_path)) { file_path = ModOrginizerPathFix(file_path); } Color orig_color = curr_btn_trans.gameObject.GetComponent <Image>().color; curr_btn_trans.gameObject.GetComponent <Image>().color = new Color(0f, 0f, 0f, 1f); yield return(new WaitForSeconds(0.3f)); curr_btn_trans.gameObject.GetComponent <Image>().color = orig_color; using (WWW www = new WWW("file:///" + file_path)) { yield return(www); if (!string.IsNullOrEmpty(www.error)) { throw new Exception(www.error); } Texture2D texture = PngAssist.ChangeTextureFromByte(www.bytes); var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); curr_btn_trans.gameObject.GetComponent <Image>().sprite = sprite; bSavingInProgress = false; } optionspanel.gameObject.SetActive(false); confirmpanel.gameObject.SetActive(false); confirmpanel2.gameObject.SetActive(false); SetLastLoadedMarkParentObj(curr_btn_trans, true); }
public static Sprite LoadSpriteFromFile(string path) { using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { long pngSize = PngFile.GetPngSize((Stream)fileStream); if (pngSize == 0L) { return((Sprite)null); } using (BinaryReader binaryReader = new BinaryReader((Stream)fileStream)) { byte[] data = binaryReader.ReadBytes((int)pngSize); int width = 0; int height = 0; Texture2D texture2D = PngAssist.ChangeTextureFromPngByte(data, ref width, ref height, (TextureFormat)5, false); return(Object.op_Equality((Object)null, (Object)texture2D) ? (Sprite)null : Sprite.Create(texture2D, new Rect(0.0f, 0.0f, (float)width, (float)height), new Vector2(0.5f, 0.5f))); } } }
public static Texture2D LoadTexture(byte[] bytes) { Texture2D result = null; using (MemoryStream memStream = new MemoryStream(bytes)) { long pngSize = PngFile.GetPngSize(memStream); if (pngSize != 0L) { using (BinaryReader binaryReader = new BinaryReader(memStream)) { byte[] data = binaryReader.ReadBytes((int)pngSize); int width = 0, height = 0; result = PngAssist.ChangeTextureFromPngByte(data, ref width, ref height); } } } return(result); }
private void SetPage(int _page, bool _force = false) { if (!_force && this.page == _page) { return; } _page = Mathf.Clamp(_page, 0, this.pageNum - 1); int num = this.thumbnailLimit * _page; for (int index = 0; index < this.thumbnailLimit; ++index) { int n = num + index; if (!MathfEx.RangeEqualOn <int>(0, n, this.thumbnailNum - 1)) { if (_page == 0 && index == 0) { this.rawsThumbnail[index].set_texture(this.textureNoData); ((Behaviour)this.rawsThumbnail[index]).set_enabled(true); } else { ((Behaviour)this.rawsThumbnail[index]).set_enabled(false); } ((Behaviour)this.buttonsThumbnail[index]).set_enabled(false); } else { this.rawsThumbnail[index].set_texture((Texture)PngAssist.LoadTexture(this.listPath[n])); ((Behaviour)this.rawsThumbnail[index]).set_enabled(true); ((Behaviour)this.buttonsThumbnail[index]).set_enabled(true); ((Selectable)this.buttonsThumbnail[index]).set_interactable(true); } } this.page = _page; if (_force && this.view.ItemList.FirstOrDefault <LoopListViewItem2>((Func <LoopListViewItem2, bool>)(_v => _v.ItemIndex == _page)) is PageButton pageButton) { pageButton.Select(); } Resources.UnloadUnusedAssets(); GC.Collect(); }
public void SetPatternTex(int _idx, string _path) { if (_path.IsNullOrEmpty()) { this.itemInfo.colors[_idx].pattern.key = 0; this.itemInfo.colors[_idx].pattern.filePath = string.Empty; this.itemComponent.SetPatternTex(_idx, (Texture2D)null); this.ReleasePatternTex(_idx); } else { this.itemInfo.colors[_idx].pattern.key = -1; this.itemInfo.colors[_idx].pattern.filePath = _path; if (File.Exists(_path)) { this.texturePattern[_idx] = PngAssist.LoadTexture(_path); } this.itemComponent.SetPatternTex(_idx, this.texturePattern[_idx]); Resources.UnloadUnusedAssets(); } }
IEnumerator LoadButtonsAsync(Transform parent, List <KeyValuePair <DateTime, string> > scenefiles) { string categoryText = category.captionText.text; foreach (var scene in scenefiles) { LoadingIcon.loadingState[categoryText] = true; using (WWW www = new WWW("file:///" + scene.Value)) { yield return(www); if (!string.IsNullOrEmpty(www.error)) { throw new Exception(www.error); } CreateSceneButton(parent, PngAssist.ChangeTextureFromByte(www.bytes), scene.Value); } } LoadingIcon.loadingState[categoryText] = false; }