关于ScrollView02
来源:互联网 发布:centos查看ssh端口 编辑:程序博客网 时间:2024/06/07 01:23
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using WhtGame;
using System.IO;
using System;
using System.Collections.Generic;
using UnityEngine.UI;
using System.Collections;
using WhtGame;
using System.IO;
using System;
using System.Collections.Generic;
public class UINews : UIBaseWindow
{
{
public RawImage pic;
public Text title;
public Text content;
public Text dateTime;
private Vector2 contentSize;
public GameObject scrollView;
public GameObject contents;
public Scrollbar ScroVertical;
// HideInInspector]
// public NewsRoot obj;
public Text title;
public Text content;
public Text dateTime;
private Vector2 contentSize;
public GameObject scrollView;
public GameObject contents;
public Scrollbar ScroVertical;
// HideInInspector]
// public NewsRoot obj;
private ScrollRect newScrollView;
private int WorkId;
private bool saveFile;
private int WorkId;
private bool saveFile;
[HideInInspector]
public GlobalControl glb_Control;
public GlobalControl glb_Control;
void Awake ()
{
contentSize = content.gameObject.GetComponent<RectTransform>().sizeDelta;
// newScrollView.vertical = false;
BtnOnClick ("UINews_MsgBtn", this.OnClick);
WorkId = 0;
// obj = new NewsRoot ();
//glb_Control = GameObject.Find ("UIManager").GetComponent<GlobalControl> ();
}
private void OnClick (GameObject go)
{
if (go.name == "UINews_MsgBtn") {
OnUIHide ();
}
}
OnUIHide ();
}
}
public void SetImg (string thumb)
{
StartCoroutine (HTTPClient.GetInstance ().LoadTexture (thumb, RectTexture));
Debug.Log (pic.texture.name);
}
//赋值图片
public void RectTexture (Texture2D tex)
{
if (tex != null) {
pic.texture = tex;
}
}
Debug.Log (pic.texture.name);
}
//赋值图片
public void RectTexture (Texture2D tex)
{
if (tex != null) {
pic.texture = tex;
}
}
private void Dynamic(string intro)
{
int rows = intro.Length / 23;
int redundant = intro.Length % 23;
if (redundant==0)
{
content.gameObject.GetComponent<RectTransform>().sizeDelta=new Vector2(contentSize.x,(rows)*43);
}
else
{
content.gameObject.GetComponent<RectTransform>().sizeDelta=new Vector2(contentSize.x,(rows+1)*43);
}
newScrollView=scrollView.GetComponent<ScrollRect>();
float height = 0;
RectTransform[] rect=contents.transform.GetComponentsInChildren<RectTransform>();
foreach (RectTransform item in rect)
{
height += item.rect.height;
Debug.Log(height);
}
//contents的子物体包含了他自己
height = height - 4800;
Debug.Log(height);
if (height <= 1450)
{
newScrollView.vertical = false;
}
else
{
newScrollView.vertical = true;
}
}
public void SetInfo (string img, string tit, string intro, string datetime)
{
//Debug.Log(content.text.Length);
//Debug.Log(intro.Length);
SetImg (img);
title.text = tit;
content.text = intro;
dateTime.text = datetime;
Dynamic(intro);
#region
//int rows= intro.Length / 23;
//int redundant=intro.Length%23;
//if (redundant == 0)
//{
// content.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(contentSize.x, (rows) * 43);
//}
//else
//{
// content.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(contentSize.x, (rows + 1) * 43);
//else
//{
// content.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(contentSize.x, (rows + 1) * 43);
//}
//newScrollView = scrollView.GetComponent<ScrollRect>();
//float height=0;
//RectTransform[] rect = contents.transform.GetComponentsInChildren<RectTransform>();
//foreach (RectTransform item in rect)
//{
// height += item.rect.height;
// Debug.Log(height);
//}
////contents的子物体包含了他自己
// height=height - 4800;
// Debug.Log(height);
//if (height <= 1450)
//{
// newScrollView.vertical = false;
//}
//else
//{
// newScrollView.vertical = true;
//}
#endregion
}
//newScrollView = scrollView.GetComponent<ScrollRect>();
//float height=0;
//RectTransform[] rect = contents.transform.GetComponentsInChildren<RectTransform>();
//foreach (RectTransform item in rect)
//{
// height += item.rect.height;
// Debug.Log(height);
//}
////contents的子物体包含了他自己
// height=height - 4800;
// Debug.Log(height);
//if (height <= 1450)
//{
// newScrollView.vertical = false;
//}
//else
//{
// newScrollView.vertical = true;
//}
#endregion
}
public override void OnUIShow ()
{
//SetInfo ();
}
{
//SetInfo ();
}
public override void OnUIHide ()
{
UIManager.GetInstance ().HideWindow (WindowID.WindowID_UINews);
UIManager.GetInstance ().ShowWindow (WindowID.WindowID_Home);
UIManager.GetInstance ().ShowWindow (WindowID.WindowID_UIMainMenu);
}
void Update() {
UIManager.GetInstance ().ShowWindow (WindowID.WindowID_Home);
UIManager.GetInstance ().ShowWindow (WindowID.WindowID_UIMainMenu);
}
void Update() {
if ( newScrollView.vertical ==false)
{
ScroVertical.value = 1;
}
}
}
{
ScroVertical.value = 1;
}
}
}
0 0
- 关于ScrollView02
- 关于
- 关于
- 关于++,--
- 关于#
- 关于。。。
- 关于
- 关于......
- 关于
- 关于
- 关于****
- 关于
- 关于!
- 关于++
- 关于
- 关于
- 关于$?
- 关于%
- 该出手时就出手
- packer-ng-plugin(快速打包神器)初略使用
- 前端如何接收 websocket 发送过来的实时数据
- 春招攻略
- 查找四位数的吸血鬼数字(java编程思想)
- 关于ScrollView02
- python 关于MySQL-python或者MySQLdb安装的几次报错的经验总结
- 怎样使用PDF阅读器浏览查看PDF文档
- solr5.5+tomcate7部署
- MxNet系列——get_started——amazonlinux_setup
- 蟠桃记
- web textarea
- Opengl函数(2)
- Spring Boot学习---1.快速构建mvc模式项目