在导入一个插件的时候,加入自己的广告

来源:互联网 发布:解放战争国民党知乎 编辑:程序博客网 时间:2024/05/01 20:01
Hello,我是KitStar。

以下文章整理的不对。还请见谅。



自己上代码。可以在一个插件中加入自己的广告。然后在别人使用的时候,在导入Unity时完美的展现出来。转自Siki老师的源代码。





using UnityEditor;using UnityEngine;[InitializeOnLoad]public class Appload{    static Appload()    {        bool hasKey = PlayerPrefs.HasKey("sikiwelcomescreen");        if (hasKey==false)        {            //EditorApplication.update += Update;            PlayerPrefs.SetInt("sikiwelcomescreen", 1);            WelcomeScreen.ShowWindow();        }    }    //static void Update()     //{    //    bool isSuccess = EditorApplication.ExecuteMenuItem("Welcome Screen");    //    if (isSuccess) EditorApplication.update -= Update;    //}}public class WelcomeScreen : EditorWindow{    private Texture mSamplesImage;    private Rect imageRect = new Rect(30f, 90f, 350f, 350f);    private Rect textRect = new Rect(15f, 15f, 380f, 100f);    public void OnEnable()    {        //this.mWelcomeScreenImage = EditorGUIUtility.Load("WelcomeScreenHeader.png") as Texture;        //BehaviorDesignerUtility.LoadTexture("WelcomeScreenHeader.png", false, this);        this.mSamplesImage = LoadTexture("wechat.jpg");    }        Texture LoadTexture(string name)    {        string path = "Assets/Demigiant/Editor/";        return (Texture)AssetDatabase.LoadAssetAtPath(path + name, typeof(Texture));    }    public void OnGUI()    {        //GUI.DrawTexture(this.mWelcomeScreenImageRect, this.mWelcomeScreenImage);        GUIStyle style = new GUIStyle();        style.fontSize = 14;        style.normal.textColor = Color.white;        GUI.Label(this.textRect, "欢迎扫一扫siki的微信,关注微信号\n我会在上面推送一套关于独立游戏开发者的游戏视频教程 免费的!\n时刻更新中!\n这个页面只会显示一次",style);        GUI.DrawTexture(this.imageRect, this.mSamplesImage);    }        public static void ShowWindow()    {        WelcomeScreen window = EditorWindow.GetWindow<WelcomeScreen>(true, "Hello 你好 我是你们最亲爱的siki老师");        window.minSize = window.maxSize = new Vector2(410f, 470f);        UnityEngine.Object.DontDestroyOnLoad(window);    }}



0 0
原创粉丝点击