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(typeof(GameSession).Name)); // obj.name = (typeof(GameSession).Name); //} //[MenuItem("GameObject/XR/GameNode", priority = 0)] //static void CreateXRNode() //{ // var obj = Instantiate(Resources.Load(typeof(GameNode).Name)); // obj.name = (typeof(GameNode).Name); //} /// /// 打包模式 /// public SerializedProperty buildType; /// /// 资源访问方式 /// public SerializedProperty assetsType; /// /// 运行的平台 /// public SerializedProperty buildTarget; /// /// 运行的模式 /// public SerializedProperty playType; /// /// 发布的平台 /// 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(); } ///// ///// 获取APP版本号,如果不存在,则从1.0.0.0开始计时 ///// //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); } } } } }