webGL build 补充

This commit is contained in:
qiangye2 2022-02-24 11:45:36 +08:00
parent 07693d4c4b
commit b3705b1980
6 changed files with 265 additions and 0 deletions

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using UnityEditor;
namespace Pack
{
[Serializable]
public partial class PackPlatformWebGl : PackPlatformUnity
{
public string leBian_MainChId = "69035";
public string leBian_ClientChId = "wenting_test";
public string leBian_SECID = "tx75web0.c";
public List<string> plugins = new List<string>()
{
// "common",
};
public List<string> sdkBridges = new List<string>()
{
};
public override BuildTarget GetBuildTarget()
{
return BuildTarget.WebGL;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aefe156bd53302c469e2ba5fb8e6c77d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEditor;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif
namespace Pack
{
public partial class PackPlatformWebGl
{
protected override string GetBuildOutputPath()
{
// iOS 的XCode项目路径最好不能有中文否则易出错
string path = Application.dataPath + PackConstant.BuildAppPath + "/" + GetBuildTarget() + "/" + channelUniqueId;
path = Path.GetFullPath(path).Replace('\\', '/');
return path + "/WebGlProj";
}
public override void BuildClear()
{
base.BuildClear();
DeleteDirectoryAssets(Path.GetFullPath(Application.dataPath + PackConstant.PluginiOSDestPath), true);
DeleteDirectoryAssets(Path.GetFullPath(Application.dataPath + PackConstant.SDKBridgeDestPath), true);
}
protected override void ChangePlayerSettings()
{
base.ChangePlayerSettings();
PlayerSettings.bundleVersion = gameVersionCode.ToString(true);
}
protected override void ChangePlatformSpecial()
{
base.ChangePlatformSpecial();
EditorUtility.DisplayProgressBar("平台特殊设置", "开始平台特殊设置", 0);
if (plugins != null && plugins.Count > 0)
{
CopyUnityAssets(Application.dataPath + PackConstant.PluginWebGlSrcPath
, plugins
, Application.dataPath + PackConstant.PluginWebGlDestPath
, Application.dataPath + PackConstant.PluginWebGlSrcMetaPath
, Application.dataPath + PackConstant.PluginWebGlDestMetaPath);
}
EditorUtility.DisplayProgressBar("平台特殊设置", "平台特殊设置", 0.5f);
if (sdkBridges != null && sdkBridges.Count > 0)
{
CopyUnityAssets(Application.dataPath + PackConstant.SDKBridgeSrcPath
, sdkBridges
, Application.dataPath + PackConstant.SDKBridgeDestPath
, Application.dataPath + PackConstant.SDKBridgeSrcMetaPath
, Application.dataPath + PackConstant.SDKBridgeDestMetaPath);
}
EditorUtility.DisplayProgressBar("平台特殊设置", "完成平台特殊设置", 1);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f7c208f4477eb664f9bbfa98d80611c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,143 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEditor;
namespace Pack
{
public partial class PackPlatformWebGl
{
private List<string> m_NeedFulplugins = new List<string>()
{
"common",
};
private DirectoryReorderableList m_PluginReorderableList;
private List<string> m_NeedFulSDKBridges = new List<string>()
{
};
private DirectoryReorderableList m_SdkBridgeReorderableList;
protected override bool HasPlatformSpecialGUI()
{
return true;
}
protected override void DrawPlatformSpecialGUI(bool editable, PackPlatformBase sourcePackPlatform)
{
base.DrawPlatformSpecialGUI(editable, sourcePackPlatform);
PackPlatformWebGl sourcePackPlatformWebGl = sourcePackPlatform as PackPlatformWebGl;
EditorGUILayout.Space();
if (ArrayUtility.Contains(defineSymbols, "BUGLY"))
{
if (!m_NeedFulplugins.Contains("Bugly"))
{
m_NeedFulplugins.Add("Bugly");
}
if (!m_NeedFulSDKBridges.Contains("Bugly"))
{
m_NeedFulSDKBridges.Add("Bugly");
}
}
for (int i = 0, iMax = m_NeedFulplugins.Count; i < iMax; i++)
{
if (i >= plugins.Count)
{
plugins.Add(m_NeedFulplugins[i]);
}
else if (plugins[i] != m_NeedFulplugins[i])
{
plugins.Remove(m_NeedFulplugins[i]);
plugins.Insert(0, m_NeedFulplugins[i]);
}
}
for (int i = plugins.Count - 1; i >= 0; i--)
{
if (!Directory.Exists(Path.GetFullPath(Application.dataPath + PackConstant.PluginWebGlSrcPath + plugins[i])))
{
plugins.RemoveAt(i);
}
}
if (m_PluginReorderableList == null)
{
m_PluginReorderableList = new DirectoryReorderableList(plugins, sourcePackPlatformWebGl.plugins, m_NeedFulplugins, Application.dataPath + PackConstant.PluginWebGlSrcPath);
}
else
{
m_PluginReorderableList.SetParams(plugins, sourcePackPlatformWebGl.plugins, m_NeedFulplugins, Application.dataPath + PackConstant.PluginWebGlSrcPath);
}
float height = m_PluginReorderableList.GetHeight();
Rect totalPosition = EditorGUILayout.GetControlRect(true, height, PackGUI.styles.label);
Rect labelPosition = new Rect(totalPosition.x + PackGUI.indent, totalPosition.y, EditorGUIUtility.labelWidth - PackGUI.indent, PackGUI.kSingleLineHeight);
int id = GUIUtility.GetControlID(PackGUI.s_DelayedTextFieldHash, FocusType.Keyboard, labelPosition);
EditorGUI.HandlePrefixLabel(totalPosition, labelPosition, EditorGUIUtility.TrTextContent("webGl目录替换", PackConstant.PluginWebGlDestPath), id, PackGUI.styles.label);
Rect fieldPosition = new Rect(totalPosition.x + PackGUI.indent + EditorGUIUtility.labelWidth, totalPosition.y, totalPosition.width - PackGUI.indent - EditorGUIUtility.labelWidth - 100, height);
Rect resetPosition = new Rect(totalPosition.x + totalPosition.width - 90, totalPosition.y, 80, PackGUI.kSingleLineHeight);
m_PluginReorderableList.DoList(fieldPosition);
if (!ArrayUtility.ArrayEquals(sourcePackPlatformWebGl.plugins.ToArray(), plugins.ToArray()))
{
if (GUI.Button(resetPosition, EditorGUIUtility.TrTextContent("重置默认", string.Join(";", sourcePackPlatformWebGl.plugins)), PackGUI.styles.miniButton))
{
plugins.Clear();
plugins.AddRange(sourcePackPlatformWebGl.plugins);
}
}
for (int i = 0, iMax = m_NeedFulSDKBridges.Count; i < iMax; i++)
{
if (i >= sdkBridges.Count)
{
sdkBridges.Add(m_NeedFulSDKBridges[i]);
}
else if (sdkBridges[i] != m_NeedFulSDKBridges[i])
{
sdkBridges.Remove(m_NeedFulSDKBridges[i]);
sdkBridges.Insert(0, m_NeedFulSDKBridges[i]);
}
}
for (int i = sdkBridges.Count - 1; i >= 0; i--)
{
if (!Directory.Exists(Path.GetFullPath(Application.dataPath + PackConstant.SDKBridgeSrcPath + sdkBridges[i])))
{
sdkBridges.RemoveAt(i);
}
}
if (m_SdkBridgeReorderableList == null)
{
m_SdkBridgeReorderableList = new DirectoryReorderableList(sdkBridges, sourcePackPlatformWebGl.sdkBridges, m_NeedFulSDKBridges, Application.dataPath + PackConstant.SDKBridgeSrcPath);
}
else
{
m_SdkBridgeReorderableList.SetParams(sdkBridges, sourcePackPlatformWebGl.sdkBridges, m_NeedFulSDKBridges, Application.dataPath + PackConstant.SDKBridgeSrcPath);
}
height = m_SdkBridgeReorderableList.GetHeight();
totalPosition = EditorGUILayout.GetControlRect(true, height, PackGUI.styles.label);
labelPosition = new Rect(totalPosition.x + PackGUI.indent, totalPosition.y, EditorGUIUtility.labelWidth - PackGUI.indent, PackGUI.kSingleLineHeight);
id = GUIUtility.GetControlID(PackGUI.s_DelayedTextFieldHash, FocusType.Keyboard, labelPosition);
EditorGUI.HandlePrefixLabel(totalPosition, labelPosition, EditorGUIUtility.TrTextContent("SDKBridge目录替换", PackConstant.SDKBridgeDestPath), id, PackGUI.styles.label);
fieldPosition = new Rect(totalPosition.x + PackGUI.indent + EditorGUIUtility.labelWidth, totalPosition.y, totalPosition.width - PackGUI.indent - EditorGUIUtility.labelWidth - 100, height);
resetPosition = new Rect(totalPosition.x + totalPosition.width - 90, totalPosition.y, 80, PackGUI.kSingleLineHeight);
m_SdkBridgeReorderableList.DoList(fieldPosition);
if (!ArrayUtility.ArrayEquals(sourcePackPlatformWebGl.sdkBridges.ToArray(), sdkBridges.ToArray()))
{
if (GUI.Button(resetPosition, EditorGUIUtility.TrTextContent("重置默认", string.Join(";", sourcePackPlatformWebGl.sdkBridges)), PackGUI.styles.miniButton))
{
sdkBridges.Clear();
sdkBridges.AddRange(sourcePackPlatformWebGl.sdkBridges);
}
}
if (plugins.Contains("Lebian"))
{
EditorGUILayout.Space();
PackGUI.DrawDelayedTextField("乐变MainChId", sourcePackPlatformWebGl.leBian_MainChId, ref leBian_MainChId, true);
PackGUI.DrawDelayedTextField("乐变ClientChId", sourcePackPlatformWebGl.leBian_ClientChId, ref leBian_ClientChId, true);
PackGUI.DrawDelayedTextField("乐变SECID", sourcePackPlatformWebGl.leBian_SECID, ref leBian_SECID, true);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e510c4d44a5c9d74f8e285e7f07767b3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: