当前位置:网站首页>Common knowledge of unity Editor Extension

Common knowledge of unity Editor Extension

2022-07-04 16:06:00 jjegoing

  • OnGUI When to call a function
    OnGUI The function is called at least twice in each frame ,OnGUI Yes Event Respond to events , among layout and repaint Events are executed at least once per frame .Events Types include mouse clicks 、 Mouse drag 、 Press the button 、 The mouse enters or exits the window 、 Rollers and other types mentioned below . For each event , Call... In these scripts OnGUI; Therefore, each frame may be called many times OnGUI. Event.current Corresponding to OnGUI Within call “ At present ” event . The occurrence of these events will lead to OnGUI Function called .
     Judging from this attribute leads to this OnGUI The type of event called
    Besides , Found through official documents ,layout The event will be sent before any other event . Insert picture description here
    Found by test , No matter how the user operates, some events will happen , Before that, it will lead to layout The occurrence of the incident
     Insert picture description here

  • About layout Refer to this article for the introduction class of
    Personal understanding is in layout In the event GUI The layout of the elements , And then Repant Draw in the event .

  • Use AnimBool as well as EditorGUILayout.BeginFadeGroup To reach the editor GUI Animation effect of

  •  Cases from official documents
    Note the following statement :
    m_ShowExtraFields.valueChanged.AddListener(Repaint);
    At this time value yes bool type , Not true namely false, At first, I thought it was when value The event is triggered when the value of is switched , By calling Repaint Callback .
     Insert picture description here
    Found by test , When faded This event will be triggered when the value changes . So when window Interface Click √ when ,fade From
    0 adopt lerp Change to 1, The process of change will trigger Repaint Method's callback ,Repaint Will trigger Event.repaint Events ,Event.repaint It can lead to OnGUI Execution of a function .
     Insert picture description here
     Insert picture description here
    Incoming AnimBool Of fade Value can make window Upper GUI Achieve the animation effect from never displaying to fully displaying .

原网站

版权声明
本文为[jjegoing]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141204202516.html