Advertisement
Guest User

MaterialUI App Bar script concept by HRoland

a guest
Apr 6th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.47 KB | None | 0 0
  1. //  Made by Roland Horváth :P
  2.  
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. namespace MaterialUI
  7. {
  8.     [ExecuteInEditMode]
  9.     public class MaterialAppBar : MonoBehaviour
  10.     {
  11.         [SerializeField]
  12.         private Graphic m_PanelLayer;
  13.         public Graphic panelLayer
  14.         {
  15.             get { return m_PanelLayer; }
  16.             set { m_PanelLayer = value; }
  17.         }
  18.  
  19.         [SerializeField]
  20.         private Graphic m_ShadowImage;
  21.         public Graphic shadowImage
  22.         {
  23.             get { return m_ShadowImage; }
  24.             set { m_ShadowImage = value; }
  25.         }
  26.  
  27.         [SerializeField]
  28.         private Text m_TitleText;
  29.         public Text titleText
  30.         {
  31.             get { return m_TitleText; }
  32.             set { m_TitleText = value; }
  33.         }
  34.  
  35.         [SerializeField]
  36.         private string m_Title;
  37.         public string title
  38.         {
  39.             get { return m_Title; }
  40.             set { m_Title = value; }
  41.         }
  42.  
  43.         [SerializeField]                //<INSERT ICON PICKER HERE>
  44.         private VectorImage m_Icon;
  45.         public VectorImage icon
  46.         {
  47.             get { return m_Icon; }
  48.             set { m_Icon = value; }
  49.         }
  50.  
  51.         [SerializeField]
  52.         private Color m_PanelColor;
  53.         public Color panelColor
  54.         {
  55.             get { return m_PanelColor; }
  56.             set { m_PanelColor = value; }
  57.         }
  58.            
  59.         [SerializeField]
  60.         private float m_AnimationLength;
  61.         public float animationLength
  62.         {
  63.             get { return m_AnimationLength; }
  64.             set { m_AnimationLength = value; }
  65.         }      
  66.  
  67.         [SerializeField]
  68.         private bool m_BackgroundVisible;
  69.         public bool backgroundVisible
  70.         {
  71.             get { return m_BackgroundVisible; }
  72.             set { m_BackgroundVisible = value; }
  73.         }  
  74.            
  75.         private void Update() //SORRY I KNOW THIS IS A HORRIBLE WAY BUT I DONT KNOW ANY OTHER WAY TO ASSIGN THE VALUES REAL-TIME. PLEASE HELP. IM BAD AT THIS
  76.         {
  77.             m_TitleText.text = m_Title;
  78.             m_ShadowImage.color = m_PanelColor;
  79.         }
  80.  
  81.         public void ShowBarBackground(bool animate)
  82.         {
  83.             if (m_BackgroundVisible)
  84.                 return;
  85.  
  86.             m_ShadowImage.CrossFadeAlpha(1, animate ? m_AnimationLength : 0, false);
  87.             m_PanelLayer.CrossFadeAlpha(1, animate ? m_AnimationLength : 0, false);
  88.             m_BackgroundVisible = true;
  89.         }
  90.  
  91.         public void HideBarBackground(bool animate)
  92.         {
  93.             if (!m_BackgroundVisible)
  94.                 return;
  95.  
  96.             m_PanelLayer.CrossFadeAlpha(0, animate ? m_AnimationLength : 0, false);
  97.             m_ShadowImage.CrossFadeAlpha(0, animate ? m_AnimationLength : 0, false);
  98.             m_BackgroundVisible = false;
  99.         }
  100.  
  101.         public void ToggleBarBackground(bool animate)
  102.         {
  103.             if (!m_BackgroundVisible) ShowBarBackground(animate);
  104.             else if (m_BackgroundVisible) HideBarBackground(animate);
  105.         }
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement