123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- /*
- http://www.cgsoso.com/forum-211-1.html
- CG搜搜 Unity3d 每日Unity3d插件免费更新 更有VIP资源!
- CGSOSO 主打游戏开发,影视设计等CG资源素材。
- 插件如若商用,请务必官网购买!
- daily assets update for try.
- U should buy the asset from home store if u use it in your project!
- */
- using UnityEngine;
- using System.Collections;
- using UnityEditor;
- public class PRParoxeBanner
- {
- Texture2D m_ParoxeIcon;
- Texture2D m_TwitterIcon;
- Texture2D m_RatingIcon;
- Texture2D m_FacebookIcon;
- Texture2D m_OpenedIcon;
- Texture2D m_ClosedIcon;
- string m_Path;
- string ParoxePath
- {
- get { return Path("Paroxe32.png"); }
- }
- string TwitterPath
- {
- get { return Path("Twitter32.png"); }
- }
- string FacebookPath
- {
- get { return Path("Facebook32.png"); }
- }
- string RatingPath
- {
- get { return Path("Rating32.png"); }
- }
- string OpenedPath
- {
- get { return Path("Open32.png"); }
- }
- string ClosedPath
- {
- get { return Path("Close32.png"); }
- }
- public PRParoxeBanner(string path)
- {
- m_Path = path;
- Intilialize();
- }
- string Path(string rel)
- {
- return m_Path + "/" + rel;
- }
- Texture2D GetTexture(string path)
- {
- Texture2D tex = (Texture2D)AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D));
- tex.hideFlags = HideFlags.HideAndDontSave;
- return tex;
- }
- void Intilialize()
- {
- m_ParoxeIcon = GetTexture(ParoxePath);
- m_TwitterIcon = GetTexture(TwitterPath);
- m_RatingIcon = GetTexture(RatingPath);
- m_FacebookIcon = GetTexture(FacebookPath);
- m_OpenedIcon = GetTexture(OpenedPath);
- m_ClosedIcon = GetTexture(ClosedPath);
- }
- void Space(float width, float height)
- {
- GUILayoutUtility.GetRect(width, height);
- }
- void Space()
- {
- float w = 4.0f;
- float h = 32 * 0.75f;
- Space(w,h);
- }
- bool OnCloseOpenGUI( bool isOpened)
- {
- Texture2D icon = isOpened ? m_ClosedIcon : m_OpenedIcon;
- Rect r = GUILayoutUtility.GetRect(icon.width * 0.3f, icon.height * 0.3f);
- GUI.DrawTexture(r, icon, ScaleMode.ScaleToFit);
- if (GUI.Button(r, "", new GUIStyle()))
- {
- return !isOpened;
- }
- return isOpened;
- }
- void OnInconGUI(Texture icon, string weblink)
- {
- Rect r = GUILayoutUtility.GetRect(icon.width*0.75f, icon.height*0.75f);
- GUI.DrawTexture(r, icon, ScaleMode.ScaleToFit);
- if (GUI.Button(r, "", new GUIStyle()))
- {
- Application.OpenURL(weblink);
- }
- }
- public bool DoOnGUI(bool isOpened)
- {
- EditorGUILayout.BeginHorizontal();
- GUILayout.FlexibleSpace();
- isOpened = OnCloseOpenGUI(isOpened);
- if (isOpened)
- {
- Space();
- OnInconGUI(m_ParoxeIcon, "http://paroxe.com/");
- Space();
- OnInconGUI(m_RatingIcon, "https://www.assetstore.unity3d.com/en/#!/content/32815");
- Space();
- OnInconGUI(m_TwitterIcon, "https://twitter.com/Paroxe_dev");
- Space();
- OnInconGUI(m_FacebookIcon, "https://www.facebook.com/paroxe.multimedia/");
- }
- EditorGUILayout.EndHorizontal();
- return isOpened;
- }
- }
|