console信息显示到text上,需要一个Scroll view contenet---text

13 篇文章 0 订阅
4 篇文章 0 订阅
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.UI;

/// <summary>
/// console信息显示到text上,需要一个Scroll view   contenet---text
/// </summary>

public class DebugPanel : MonoBehaviour
{

    public static DebugPanel Instance;

    public Text logText;
    public RectTransform content;

    private int count = 0;
    private Vector2 contentVe2 = new Vector2();
    StringBuilder MyStrBulder;
    private bool isUpdate = false;

    private bool isShow = false;

    private DebugPanel()
    {
        if (Instance == null)
            Instance = this;
    }

    private string strDebg = string.Empty;

    public void AddText(string str)
    {
        isUpdate = true;
        MyStrBulder.AppendFormat("{0}:{1}\n", count, str);
        count++;
        isUpdate = false;

    }
    // Use this for initialization
    void Awake()
    {


        //Debug.LogError("ssssssssssssssssssssss");
        MyStrBulder = new StringBuilder();

#if UNITY_5
            Application.logMessageReceived += HandleLog;  
#else
        Application.logMessageReceived += HandleLog;
#endif

    }

    void HandleLog(string message, string stackTrace, LogType type)
    {
        switch (type)
        {
            case LogType.Error:
                message = "<color=#FF0000>" + message + "</color>";
                break;
            case LogType.Assert:
                message = "<color=#0000ff>" + message + "</color>";
                break;
            case LogType.Warning:
                message = "<color=#EEEE00>" + message + "</color>";
                break;
            case LogType.Log:
                message = "<color=#000000>" + message + "</color>";
                break;
            case LogType.Exception:
                break;
            default:
                break;
        }

        AddText(message);
    }

    public void ShowHide()
    {
        isShow = !isShow;
        if (isShow)
        {
            transform.GetChild(0).localPosition = new Vector3(-9990, 0, 0);
        }
        else
        {
            transform.GetChild(0).localPosition = new Vector3(0, 0, 0);
        }
    }

    private bool isAdd = false;
    // Update is called once per frame
    void Update()
    {
        logText.text = MyStrBulder.ToString();
        //logText.text += MyStrBulder;
        contentVe2.Set(200, 23.5f * count);
        content.sizeDelta = contentVe2;
    }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
根据提供的引用内容,实现微信小程序中 scroll-viewscroll-into-view 无效果可能是由以下几个原因导致的: 1. scroll-into-view 属性的值与要跳转到的锚点标记的 id 属性值一致。例如,如果要跳转到一个 id 为 "anchor1" 的锚点标记,那么 scroll-into-view 的值应该设置为 "anchor1"。 2. scroll-view 容器高度不足:如果 scroll-view 容器的高度不足以显示要跳转到的锚点标记,那么 scroll-into-view 将无法生效。确保 scroll-view 容器的高度足够大,以容纳所有的内容和要跳转到的锚点标记。 3. scroll-into-view 设置在子组件上:scroll-into-view 属性应该设置在 scroll-view 组件上,而不是其子组件上。确保 scroll-into-view 属性被正确地设置在 scroll-view 组件上。 4. scroll-into-view 设置在动态生的内容上:如果要跳转到的锚点标记是在动态生的内容中,那么需要在动态生内容之后再设置 scroll-into-view 属性。因为 scroll-into-view 属性需要等待内容渲染完后才能生效。 5. scroll-into-view 设置在隐藏的内容上:如果要跳转到的锚点标记是在初始状态下是隐藏的内容中,那么需要显示该内容后再设置 scroll-into-view 属性。因为 scroll-into-view 属性需要等待内容显示后才能生效。 以下是一个示例代码,演示了如何在微信小程序中使用 scroll-viewscroll-into-view 实现锚点跳转效果: ```html <scroll-view scroll-into-view="{{toView}}" scroll-y="true" style="height: 300px;"> <view id="anchor1">锚点1</view> <view id="anchor2">锚点2</view> <view id="anchor3">锚点3</view> <view id="anchor4">锚点4</view> <view id="anchor5">锚点5</view> </scroll-view> <button bindtap="scrollToAnchor">跳转到锚点2</button> ``` ```javascript Page({ data: { toView: '' }, scrollToAnchor: function() { this.setData({ toView: 'anchor2' }) } }) ``` 在上述示例中,scroll-view 组件设置了 scroll-into-view 属性为 toView 变量的值,当点击按钮时,toView 变量的值被设置为 "anchor2",从而实现了跳转到锚点2的效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Batman1208

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值