zoukankan      html  css  js  c++  java
  • Unity Button按钮延迟

    1.把下面脚本放到Editor文件夹下,这样脚本继承Button之后,新声明的public变量才能在Inspector面板显示出来。

    using System.Collections;
    using System.Collections.Generic;
    using UnityEditor;
    using UnityEditor.UI;
    using UnityEngine;
    
    [CustomEditor(typeof(MyButton), true)]
    [CanEditMultipleObjects]
    public class MyButtonEditor : ButtonEditor
    {
        private SerializedProperty delayTime;
    
        protected override void OnEnable()
        {
            base.OnEnable();
            delayTime = serializedObject.FindProperty("delayTime");
        }
    
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            EditorGUILayout.Space();
            serializedObject.Update();
            EditorGUILayout.PropertyField(delayTime);
            serializedObject.ApplyModifiedProperties();
        }
    }
    View Code

     

    2.把下面脚本当成Button组件用,在Inspector面板的delayTime输入想延迟的时间就行了。

    using System.Collections;
    using System.Collections.Generic;
    using UnityEditor;
    using UnityEditor.UI;
    using UnityEngine;
    
    [CustomEditor(typeof(MyButton), true)]
    [CanEditMultipleObjects]
    public class MyButtonEditor : ButtonEditor
    {
        private SerializedProperty delayTime;
    
        protected override void OnEnable()
        {
            base.OnEnable();
            delayTime = serializedObject.FindProperty("delayTime");
        }
    
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            EditorGUILayout.Space();
            serializedObject.Update();
            EditorGUILayout.PropertyField(delayTime);
            serializedObject.ApplyModifiedProperties();
        }
    }
    View Code

     

  • 相关阅读:
    eth0 no such device(reload)
    wince驱动开发入门
    如何在Linux中添加新的系统调用
    嵌入式Linux启动优化手记2 U…
    关于uboot的一些优化
    Yaffs2根文件系统制作
    kernel下制作动态logo
    linux dev/dsp 声卡学习笔记
    【JDK8】Java8 优雅的异步调用API CompletableFuture
    每周总结:2019年12月第5周
  • 原文地址:https://www.cnblogs.com/Peng18233754457/p/11435657.html
Copyright © 2011-2022 走看看