public void OnClickImage(GameObject go) { FileItemUI it = go.GetComponent <FileItemUI>(); Debug.Log(it.name); MainUIContrller.Instance.SelectFilePic(it.name); TipManager.Instance.show("图片已经选择。。。。。"); }
public void OnClickFileButton(GameObject go) { FileItemUI item = go.GetComponent <FileItemUI> (); if (item.fileItm.fileType == FileType.Img) { return; } string _path = item.fileItm.name; OpenFileList(_path); InitFilesUIs(); filePahtStack.Push(_path); }
private void InitFilesUIs() { ReturnAllResource(content); imageList.Clear(); if (ShowFileList.Count > 0) { for (int i = 0; i < ShowFileList.Count; i++) { FileItemUI itemUI = getAprefab().GetComponent <FileItemUI> (); FileItem _item = ShowFileList[i]; itemUI.fileItm = _item; if (itemUI != null) { itemUI.transform.SetParent(content, false); itemUI.textName.text = ShowFileList [i].name; if (_item.fileType == FileType.Img) { imageList.Add(itemUI.textName.text); /* * byte[] bys = File.ReadAllBytes (_item.name); * * Texture2D t = new Texture2D (300, 300); * t.LoadImage (bys); * t.Apply (); * int _width = 0; * int _height = 0; * if (t.width > 500) { * _width = 500; * _height =Mathf.RoundToInt( ((float)_width /(float) t.width) * t.height); * } * else * { * _width = t.width; * _height = t.height; * } * * if (_height > 500) { * _height = 500; * _width = Mathf.RoundToInt (((float)_height / t.height) * t.width); * } * * itemUI.showImagRawImage.gameObject.SetActive (true); * itemUI.showImagRawImage.texture= t; * itemUI.textName.gameObject.SetActive (false); * itemUI.showImagRawImage.rectTransform.SetSizeWithCurrentAnchors (RectTransform.Axis.Horizontal,_width); * itemUI.layoutItem.preferredHeight =_height; * imageCount++; */ } else { itemUI.showImagRawImage.gameObject.SetActive(false); itemUI.textName.gameObject.SetActive(true); itemUI.layoutItem.preferredHeight = 100; } } } } if (imageList.Count == 0) { showImageResult.text = "本目录,未发现图片"; } else { showImageResult.text = "发现图片 " + imageList.Count + " 张,点击加载"; } }