123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using UnityEngine;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- namespace XRTool.Util
- {
- [InitializeOnLoad]
- [CustomEditor(typeof(BuildConfig))]
- public class BuildConfigInspector : Editor
- {
- //[MenuItem("GameObject/XR/XRCompents", priority = 0)]
- //static void CreateXRCompents()
- //{
- // CreateXRSession();
- // CreateXRNode();
- //}
- //[MenuItem("GameObject/XR/GameSession", priority = 0)]
- //static void CreateXRSession()
- //{
- // var obj = Instantiate(Resources.Load<GameSession>(typeof(GameSession).Name));
- // obj.name = (typeof(GameSession).Name);
- //}
- //[MenuItem("GameObject/XR/GameNode", priority = 0)]
- //static void CreateXRNode()
- //{
- // var obj = Instantiate(Resources.Load<GameNode>(typeof(GameNode).Name));
- // obj.name = (typeof(GameNode).Name);
- //}
- /// <summary>
- /// 打包模式
- /// </summary>
- public SerializedProperty buildType;
- /// <summary>
- /// 资源访问方式
- /// </summary>
- public SerializedProperty assetsType;
- /// <summary>
- /// 运行的平台
- /// </summary>
- public SerializedProperty buildTarget;
- /// <summary>
- /// 运行的模式
- /// </summary>
- public SerializedProperty playType;
- /// <summary>
- /// 发布的平台
- /// </summary>
- public SerializedProperty buildTargetGroup;
- public SerializedProperty languagePath;
- public SerializedProperty useHand;
- private void OnEnable()
- {
- buildType = serializedObject.FindProperty("buildType");
- assetsType = serializedObject.FindProperty("assetsType");
- buildTarget = serializedObject.FindProperty("buildTarget");
- playType = serializedObject.FindProperty("playType");
- buildTargetGroup = serializedObject.FindProperty("buildTargetGroup");
- languagePath = serializedObject.FindProperty("languagePath");
- useHand = serializedObject.FindProperty("useHand");
- BuildConfig.Instance = target as BuildConfig;
- //ReadGameVersion();
- }
- ///// <summary>
- ///// 获取APP版本号,如果不存在,则从1.0.0.0开始计时
- ///// </summary>
- //public void ReadGameVersion()
- //{
- // var conf = target as BuildConfig;
- // if (conf.version == null || conf.version.version == null)
- // {
- // conf.UpdateGameVersion();
- // }
- // conf.version = DataFileUtil.Instance.ReadJsonObjFormEditor("GameData/BuildConf/Version.json", conf.version);
- // //if (conf.version != null && conf.version.version != null)
- // //{
- // // Debug.Log("版本号" + conf.version.version.ToString());
- // //}
- // PlayerSettings.bundleVersion = conf.version.version.ToString();
- //}
- public override void OnInspectorGUI()
- {
- serializedObject.Update();
- var conf = target as BuildConfig;
- if (conf.buildTarget == BuildTarget.Android)
- {
- conf.buildTargetGroup = BuildTargetGroup.Android;
- }
- if (conf.buildTarget == BuildTarget.iOS)
- {
- conf.buildTargetGroup = BuildTargetGroup.iOS;
- }
- if (conf.buildTarget == BuildTarget.StandaloneWindows)
- {
- conf.buildTargetGroup = BuildTargetGroup.Standalone;
- }
- EditorGUILayout.PropertyField(buildType, new GUIContent("打包模式,默认debug"));
- EditorGUILayout.PropertyField(assetsType, new GUIContent("资源访问方式,默认editor"));
- EditorGUILayout.PropertyField(buildTarget, new GUIContent("运行的平台,默认pc"));
- EditorGUILayout.PropertyField(playType, new GUIContent("运行的模式,默认normal"));
- EditorGUILayout.PropertyField(languagePath, new GUIContent("语言包路径"));
- EditorGUILayout.PropertyField(useHand, new GUIContent("手势"));
- //EditorGUILayout.PropertyField(buildTargetGroup, new GUIContent("发布的平台,默认Standalone"));
- conf.otherSymbol = EditorGUILayout.TextField("宏", conf.otherSymbol);
- EditorGUILayout.LabelField("Version", PlayerSettings.bundleVersion);
- EditorGUILayout.LabelField("发布时间", conf.buildTime);
- if (GUILayout.Button("重置版本号", GUILayout.Width(200)))
- {
- conf.appVersion = BuildDeployWindow.initVersion;
- PlayerSettings.bundleVersion = conf.appVersion;
- }
- serializedObject.ApplyModifiedProperties();
- if (GUI.changed)
- {
- EditorUtility.SetDirty(target);
- string lastSym = PlayerSettings.GetScriptingDefineSymbolsForGroup(conf.buildTargetGroup);
- ///设置指令用;分割
- string symbol = string.Format("buildType_{0};assetsType_{1};buildPlatform_{2};playType_{3}",
- conf.buildType, conf.assetsType, conf.buildTarget, conf.playType).ToUpper() + ";" + conf.otherSymbol;
- if (symbol != lastSym)
- {
- Debug.Log(lastSym + "当前宏编译配置" + symbol);
- PlayerSettings.SetScriptingDefineSymbolsForGroup(conf.buildTargetGroup, symbol);
- }
- }
- }
- }
- }
|