ShareSDKConfigEditor.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.IO;
  3. using System.Collections;
  4. using System.Runtime.Serialization.Formatters.Binary;
  5. using UnityEngine;
  6. using UnityEditor;
  7. namespace cn.sharesdk.unity3d
  8. {
  9. [CustomEditor(typeof(ShareSDK))]
  10. [ExecuteInEditMode]
  11. public class ShareSDKConfigEditor : Editor {
  12. private ShareSDKConfig config;
  13. void Awake()
  14. {
  15. this.config = new ShareSDKConfig ();
  16. }
  17. public override void OnInspectorGUI()
  18. {
  19. base.OnInspectorGUI();
  20. //var obj = target as ShareSDK;
  21. //this.config.appKey = obj.appKey;
  22. //this.config.appSecret = obj.appSecret;
  23. // this.config.SinaWeibo ["chosen"] = obj.devInfo.sinaweibo.Enable;
  24. // this.config.TencentWeibo ["chosen"] = obj.devInfo.tencentweibo.Enable;
  25. // this.config.DouBan ["chosen"] = obj.devInfo.douban.Enable;
  26. // this.config.QQ["chosen"] = obj.devInfo.qq.Enable;
  27. // this.config.WeChat["chosen"] = obj.devInfo.wechat.Enable;
  28. // this.config.Renren["chosen"] = obj.devInfo.renren.Enable;
  29. // this.config.Kaixin["chosen"] = obj.devInfo.kaiXin.Enable;
  30. // this.config.Facebook["chosen"] = obj.devInfo.facebook.Enable;
  31. // this.config.Evernote["chosen"] = obj.devInfo.evernote.Enable;
  32. // this.config.GooglePlus["chosen"] = obj.devInfo.googlePlus.Enable;
  33. // this.config.Instagram["chosen"] = obj.devInfo.instagram.Enable;
  34. // this.config.LinkedIn["chosen"] = obj.devInfo.linkedIn.Enable;
  35. // this.config.Tumblr["chosen"] = obj.devInfo.tumblr.Enable;
  36. // this.config.Mail["chosen"] = obj.devInfo.email.Enable;
  37. // this.config.SMS["chosen"] = obj.devInfo.shortMessage.Enable;
  38. // this.config.Print["chosen"] = obj.devInfo.shortMessage.Enable;
  39. Save ();
  40. }
  41. private void Save()
  42. {
  43. try
  44. {
  45. string filePath = Application.dataPath + "/Plugins/ShareSDK/ShareSDKConfig.bin";
  46. BinaryFormatter formatter = new BinaryFormatter();
  47. Stream stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None);
  48. formatter.Serialize(stream, this.config);
  49. stream.Flush();
  50. stream.Close();
  51. }
  52. catch (Exception e)
  53. {
  54. Debug.Log ("save error:" + e);
  55. }
  56. }
  57. }
  58. }