コード例 #1
0
 public void Initalize(ScriptableForge instance)
 {
     m_ScriptableForge     = instance;
     m_BackgroundColor     = Color.white;
     m_OpenAnimation.value = m_IsOpen;
     m_OpenAnimation.valueChanged.AddListener(m_ScriptableForge.Repaint);
     m_ScriptableForge.Repaint();
 }
コード例 #2
0
ファイル: Widget.cs プロジェクト: Powell00000/space-invaders
 public void Initalize(ScriptableForge instance)
 {
     m_ScriptableForge     = instance;
     m_BackgroundColor     = Color.white;
     m_OpenAnimation.value = m_IsOpen;
     m_ScriptableForge.Repaint();
     m_InDevelopment = Attribute.GetCustomAttribute(GetType(), typeof(InDevelopmentAttribute)) != null;
 }
コード例 #3
0
        private void FlashUpdate()
        {
            float lerpTime = m_FlashUntil - Time.realtimeSinceStartup;

            lerpTime          = Mathf.Sin(lerpTime * 20f);
            lerpTime         += 1f;
            lerpTime         /= 2f;
            m_BackgroundColor = Color.Lerp(Color.white, m_FlashColor, lerpTime);
            m_ScriptableForge.Repaint();
            if (m_FlashUntil < Time.realtimeSinceStartup)
            {
                EditorApplication.update -= FlashUpdate;
                m_BackgroundColor         = Color.white;
            }
        }
コード例 #4
0
ファイル: Widget.cs プロジェクト: Powell00000/space-invaders
        /// <summary>
        /// All drawing logic is placed inside of this method.
        /// </summary>
        public virtual void OnWidgetGUI(ScriptForgeStyles style)
        {
            GUI.backgroundColor = m_BackgroundColor;
            Rect headerRect = EditorGUILayout.BeginVertical(GUI.skin.box);

            {
                GUILayout.BeginHorizontal();
                {
                    OnTitleBarGUI(style);
                }
                GUILayout.EndHorizontal();

                headerRect.height = 30f;

                if (Event.current.type == EventType.MouseDown && headerRect.Contains(Event.current.mousePosition))
                {
                    // They left clicked.
                    if (Event.current.button == 0)
                    {
                        FlashColor(Color.gray, 0.25f);
                        m_IsOpen = !m_IsOpen;
                        GUIUtility.hotControl      = -1;
                        GUIUtility.keyboardControl = -1;
                    }
                    // They right clicked.
                    else if (Event.current.button == 1)
                    {
                        // Create our menu.
                        GenericMenu menu = new GenericMenu();
                        // Populate it
                        OnGenerateContexMenu(menu);
                        // Check if we have any elements
                        if (menu.GetItemCount() > 0)
                        {
                            // Show it.
                            menu.DropDown(headerRect);
                        }
                    }
                }

                // As long as our animation is playing we
                // want to force a repaint.
                if (m_OpenAnimation.isAnimating)
                {
                    m_ScriptableForge.Repaint();
                }

                if (EditorGUILayout.BeginFadeGroup(m_OpenAnimation.faded))
                {
                    GUILayout.Box(GUIContent.none, style.spacer);
                    if (m_ErrorCode != ScriptForgeErrors.Codes.None)
                    {
                        EditorGUILayout.HelpBox(m_ErrorMessage, MessageType.Error);
                    }
                    EditorGUI.BeginChangeCheck();
                    {
                        DrawWidgetContent(style);
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        OnContentChanged();
                    }
                    GUILayout.Box(GUIContent.none, style.spacer);
                    DrawWidgetFooter(style);
                }
                EditorGUILayout.EndFadeGroup();
            }
            EditorGUILayout.EndVertical();

            if (m_ScriptableForge.animateWidgets)
            {
                m_OpenAnimation.target = m_IsOpen;
            }
            else
            {
                m_OpenAnimation.value = m_IsOpen;
            }

            GUI.backgroundColor = Color.white;
        }