Compare commits
2 Commits
d01e2cde13
...
3881ae8232
| Author | SHA1 | Date | |
|---|---|---|---|
| 3881ae8232 | |||
| 5510c1f3fe |
128
Assets/Scenes/MAIN.unity
Normal file
128
Assets/Scenes/MAIN.unity
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!29 &1
|
||||||
|
OcclusionCullingSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_OcclusionBakeSettings:
|
||||||
|
smallestOccluder: 5
|
||||||
|
smallestHole: 0.25
|
||||||
|
backfaceThreshold: 100
|
||||||
|
m_SceneGUID: 00000000000000000000000000000000
|
||||||
|
m_OcclusionCullingData: {fileID: 0}
|
||||||
|
--- !u!104 &2
|
||||||
|
RenderSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 9
|
||||||
|
m_Fog: 0
|
||||||
|
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
m_FogMode: 3
|
||||||
|
m_FogDensity: 0.01
|
||||||
|
m_LinearFogStart: 0
|
||||||
|
m_LinearFogEnd: 300
|
||||||
|
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||||
|
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||||
|
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||||
|
m_AmbientIntensity: 1
|
||||||
|
m_AmbientMode: 0
|
||||||
|
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||||
|
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_HaloStrength: 0.5
|
||||||
|
m_FlareStrength: 1
|
||||||
|
m_FlareFadeSpeed: 3
|
||||||
|
m_HaloTexture: {fileID: 0}
|
||||||
|
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
m_DefaultReflectionMode: 0
|
||||||
|
m_DefaultReflectionResolution: 128
|
||||||
|
m_ReflectionBounces: 1
|
||||||
|
m_ReflectionIntensity: 1
|
||||||
|
m_CustomReflection: {fileID: 0}
|
||||||
|
m_Sun: {fileID: 0}
|
||||||
|
m_UseRadianceAmbientProbe: 0
|
||||||
|
--- !u!157 &3
|
||||||
|
LightmapSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 12
|
||||||
|
m_GIWorkflowMode: 1
|
||||||
|
m_GISettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_BounceScale: 1
|
||||||
|
m_IndirectOutputScale: 1
|
||||||
|
m_AlbedoBoost: 1
|
||||||
|
m_EnvironmentLightingMode: 0
|
||||||
|
m_EnableBakedLightmaps: 1
|
||||||
|
m_EnableRealtimeLightmaps: 0
|
||||||
|
m_LightmapEditorSettings:
|
||||||
|
serializedVersion: 12
|
||||||
|
m_Resolution: 2
|
||||||
|
m_BakeResolution: 40
|
||||||
|
m_AtlasSize: 1024
|
||||||
|
m_AO: 0
|
||||||
|
m_AOMaxDistance: 1
|
||||||
|
m_CompAOExponent: 1
|
||||||
|
m_CompAOExponentDirect: 0
|
||||||
|
m_ExtractAmbientOcclusion: 0
|
||||||
|
m_Padding: 2
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_LightmapsBakeMode: 1
|
||||||
|
m_TextureCompression: 1
|
||||||
|
m_FinalGather: 0
|
||||||
|
m_FinalGatherFiltering: 1
|
||||||
|
m_FinalGatherRayCount: 256
|
||||||
|
m_ReflectionCompression: 2
|
||||||
|
m_MixedBakeMode: 2
|
||||||
|
m_BakeBackend: 1
|
||||||
|
m_PVRSampling: 1
|
||||||
|
m_PVRDirectSampleCount: 32
|
||||||
|
m_PVRSampleCount: 512
|
||||||
|
m_PVRBounces: 2
|
||||||
|
m_PVREnvironmentSampleCount: 256
|
||||||
|
m_PVREnvironmentReferencePointCount: 2048
|
||||||
|
m_PVRFilteringMode: 1
|
||||||
|
m_PVRDenoiserTypeDirect: 1
|
||||||
|
m_PVRDenoiserTypeIndirect: 1
|
||||||
|
m_PVRDenoiserTypeAO: 1
|
||||||
|
m_PVRFilterTypeDirect: 0
|
||||||
|
m_PVRFilterTypeIndirect: 0
|
||||||
|
m_PVRFilterTypeAO: 0
|
||||||
|
m_PVREnvironmentMIS: 1
|
||||||
|
m_PVRCulling: 1
|
||||||
|
m_PVRFilteringGaussRadiusDirect: 1
|
||||||
|
m_PVRFilteringGaussRadiusIndirect: 5
|
||||||
|
m_PVRFilteringGaussRadiusAO: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||||
|
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||||
|
m_ExportTrainingData: 0
|
||||||
|
m_TrainingDataDestination: TrainingData
|
||||||
|
m_LightProbeSampleCountMultiplier: 4
|
||||||
|
m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_LightingSettings: {fileID: 0}
|
||||||
|
--- !u!196 &4
|
||||||
|
NavMeshSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_BuildSettings:
|
||||||
|
serializedVersion: 3
|
||||||
|
agentTypeID: 0
|
||||||
|
agentRadius: 0.5
|
||||||
|
agentHeight: 2
|
||||||
|
agentSlope: 45
|
||||||
|
agentClimb: 0.4
|
||||||
|
ledgeDropHeight: 0
|
||||||
|
maxJumpAcrossDistance: 0
|
||||||
|
minRegionArea: 2
|
||||||
|
manualCellSize: 0
|
||||||
|
cellSize: 0.16666667
|
||||||
|
manualTileSize: 0
|
||||||
|
tileSize: 256
|
||||||
|
buildHeightMesh: 0
|
||||||
|
maxJobWorkers: 0
|
||||||
|
preserveTilesOutsideBounds: 0
|
||||||
|
debug:
|
||||||
|
m_Flags: 0
|
||||||
|
m_NavMeshData: {fileID: 0}
|
||||||
|
--- !u!1660057539 &9223372036854775807
|
||||||
|
SceneRoots:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_Roots: []
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,91 +1,91 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VersionFlow.Runtime;
|
using VersionFlow.Runtime;
|
||||||
|
|
||||||
namespace VersionFlow.Editors
|
namespace VersionFlow.Editors
|
||||||
{
|
{
|
||||||
[CustomEditor(typeof(BuilderConfig))]
|
[CustomEditor(typeof(BuilderConfig))]
|
||||||
public class BuilderConfigEditor : Editor
|
public class BuilderConfigEditor : Editor
|
||||||
{
|
{
|
||||||
static private BundleManifest RemoteVersion;
|
static private BundleManifest RemoteVersion;
|
||||||
static private string UpdateVersion;
|
static private string UpdateVersion;
|
||||||
|
|
||||||
static public BundleManifest Report;
|
static public BundleManifest Report;
|
||||||
static private List<BundleCompare> CompareResult;
|
static private List<BundleCompare> CompareResult;
|
||||||
static private string outputPath;
|
static private string outputPath;
|
||||||
static private Dictionary<string, BundleExtraInfo> bundleExtraInfo;
|
static private Dictionary<string, BundleExtraInfo> bundleExtraInfo;
|
||||||
static bool FoldOutGroup;
|
static bool FoldOutGroup;
|
||||||
|
|
||||||
private static void ResetState()
|
private static void ResetState()
|
||||||
{
|
{
|
||||||
RemoteVersion = null;
|
RemoteVersion = null;
|
||||||
UpdateVersion = null;
|
UpdateVersion = null;
|
||||||
|
|
||||||
Report = null;
|
Report = null;
|
||||||
CompareResult = null;
|
CompareResult = null;
|
||||||
outputPath = null;
|
outputPath = null;
|
||||||
bundleExtraInfo = null;
|
bundleExtraInfo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnInspectorGUI()
|
public override void OnInspectorGUI()
|
||||||
{
|
{
|
||||||
base.OnInspectorGUI();
|
base.OnInspectorGUI();
|
||||||
|
|
||||||
DrawUploader();
|
DrawUploader();
|
||||||
|
|
||||||
var builder = target as BuilderConfig;
|
var builder = target as BuilderConfig;
|
||||||
|
|
||||||
EditorGUILayout.Space(20);
|
EditorGUILayout.Space(20);
|
||||||
BuilderConfig.ShowBuilderMarker = EditorGUILayout.Toggle("在Project窗口中显示打包标记", BuilderConfig.ShowBuilderMarker);
|
BuilderConfig.ShowBuilderMarker = EditorGUILayout.Toggle("在Project窗口中显示打包标记", BuilderConfig.ShowBuilderMarker);
|
||||||
if (FoldOutGroup = EditorGUILayout.BeginFoldoutHeaderGroup(FoldOutGroup, "打包配置"))
|
if (FoldOutGroup = EditorGUILayout.BeginFoldoutHeaderGroup(FoldOutGroup, "打包配置"))
|
||||||
{
|
{
|
||||||
DrawGroupItems();
|
DrawGroupItems();
|
||||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("获取远端版本号"))
|
if (GUILayout.Button("获取远端版本号"))
|
||||||
{
|
{
|
||||||
ResetState();
|
ResetState();
|
||||||
var (remoteVersion, updateVersion) = FetchRemoteVersion(builder);
|
var (remoteVersion, updateVersion) = FetchRemoteVersion(builder);
|
||||||
RemoteVersion = remoteVersion;
|
RemoteVersion = remoteVersion;
|
||||||
UpdateVersion = updateVersion;
|
UpdateVersion = updateVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RemoteVersion != null)
|
if (RemoteVersion != null)
|
||||||
{
|
{
|
||||||
EditorGUILayout.LabelField($"远端版本号:{RemoteVersion.Version}");
|
EditorGUILayout.LabelField($"远端版本号:{RemoteVersion.Version}");
|
||||||
if (GUILayout.Button("将远端版本号复制到剪切板"))
|
if (GUILayout.Button("将远端版本号复制到剪切板"))
|
||||||
{
|
{
|
||||||
EditorGUIUtility.systemCopyBuffer = RemoteVersion.Version;
|
EditorGUIUtility.systemCopyBuffer = RemoteVersion.Version;
|
||||||
}
|
}
|
||||||
UpdateVersion = EditorGUILayout.TextField($"上传版本号", UpdateVersion);
|
UpdateVersion = EditorGUILayout.TextField($"上传版本号", UpdateVersion);
|
||||||
|
|
||||||
if (CompareResult == null && GUILayout.Button("Build"))
|
if (CompareResult == null && GUILayout.Button("Build"))
|
||||||
{
|
{
|
||||||
var bc = (BuilderConfig)target;
|
var bc = (BuilderConfig)target;
|
||||||
bc.OnCalcBundleHash = BuilderConfigEditor.CalcBundleHash;
|
bc.OnCalcBundleHash = BuilderConfigEditor.CalcBundleHash;
|
||||||
Report = bc.Build(UpdateVersion, out outputPath, out bundleExtraInfo);
|
Report = bc.Build(UpdateVersion, out outputPath, out bundleExtraInfo);
|
||||||
CompareResult = bc.CompareBundleManifest(Report, RemoteVersion);
|
CompareResult = bc.CompareBundleManifest(Report, RemoteVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CompareResult != null && Report != null && outputPath != null && bundleExtraInfo != null)
|
if (CompareResult != null && Report != null && outputPath != null && bundleExtraInfo != null)
|
||||||
{
|
{
|
||||||
DrawCompareResult(CompareResult, bundleExtraInfo);
|
DrawCompareResult(CompareResult, bundleExtraInfo);
|
||||||
if (GUILayout.Button("UPLOAD"))
|
if (GUILayout.Button("UPLOAD"))
|
||||||
{
|
{
|
||||||
StartUpLoad(CompareResult, Report, outputPath, builder.GetPatchLoader());
|
StartUpLoad(CompareResult, Report, outputPath, builder.GetPatchLoader());
|
||||||
|
|
||||||
ResetState();
|
ResetState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<PatchUploader, Editor> m_uploaderEditorMapper = new Dictionary<PatchUploader, Editor>();
|
Dictionary<PatchUploader, Editor> m_uploaderEditorMapper = new Dictionary<PatchUploader, Editor>();
|
||||||
@ -126,279 +126,284 @@ namespace VersionFlow.Editors
|
|||||||
EditorUtility.SetDirty(target);
|
EditorUtility.SetDirty(target);
|
||||||
patchLoader.CfgChanged(builder, builder.UploaderCfgDict.GetUploaderCfg(patchLoader.GetType()));
|
patchLoader.CfgChanged(builder, builder.UploaderCfgDict.GetUploaderCfg(patchLoader.GetType()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (!patchLoader.Status)
|
||||||
private void DrawGroupItems()
|
{
|
||||||
{
|
EditorGUILayout.HelpBox(patchLoader.Status, MessageType.Error);
|
||||||
Undo.RecordObject(target, target.name);
|
}
|
||||||
|
}
|
||||||
EditorGUILayout.BeginVertical();
|
|
||||||
|
private void DrawGroupItems()
|
||||||
var builder = target as BuilderConfig;
|
{
|
||||||
builder.DuplicateBundleBeInstallBundle = EditorGUILayout.Toggle("重复依赖资源的bundle作为随包资源", builder.DuplicateBundleBeInstallBundle);
|
Undo.RecordObject(target, target.name);
|
||||||
builder.ShaderBundleBeInstallBundle = EditorGUILayout.Toggle("shaderbundle作为随包资源", builder.ShaderBundleBeInstallBundle);
|
|
||||||
|
EditorGUILayout.BeginVertical();
|
||||||
foreach (var group in builder.Groups)
|
|
||||||
{
|
var builder = target as BuilderConfig;
|
||||||
var temp = GUI.color;
|
builder.DuplicateBundleBeInstallBundle = EditorGUILayout.Toggle("重复依赖资源的bundle作为随包资源", builder.DuplicateBundleBeInstallBundle);
|
||||||
|
builder.ShaderBundleBeInstallBundle = EditorGUILayout.Toggle("shaderbundle作为随包资源", builder.ShaderBundleBeInstallBundle);
|
||||||
GUI.color = GetGroupColor(group, out var errorMsg);
|
|
||||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
foreach (var group in builder.Groups)
|
||||||
{
|
{
|
||||||
EditorGUILayout.LabelField(errorMsg);
|
var temp = GUI.color;
|
||||||
//Name And Optionnal
|
|
||||||
EditorGUILayout.BeginHorizontal();
|
GUI.color = GetGroupColor(group, out var errorMsg);
|
||||||
{
|
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||||
group.MarkColor = EditorGUILayout.ColorField("标记颜色", group.MarkColor);
|
{
|
||||||
group.GroupName = EditorGUILayout.TextField(group.GroupName, GUILayout.Width(100));
|
EditorGUILayout.LabelField(errorMsg);
|
||||||
|
//Name And Optionnal
|
||||||
var groupDeleteColor = GUI.color;
|
EditorGUILayout.BeginHorizontal();
|
||||||
GUI.color = Color.red;
|
{
|
||||||
if (GUILayout.Button("X", GUILayout.Width(30)))
|
group.MarkColor = EditorGUILayout.ColorField("标记颜色", group.MarkColor);
|
||||||
{
|
group.GroupName = EditorGUILayout.TextField(group.GroupName, GUILayout.Width(100));
|
||||||
builder.Groups.Remove(group);
|
|
||||||
break;
|
var groupDeleteColor = GUI.color;
|
||||||
}
|
GUI.color = Color.red;
|
||||||
GUI.color = groupDeleteColor;
|
if (GUILayout.Button("X", GUILayout.Width(30)))
|
||||||
}
|
{
|
||||||
EditorGUILayout.EndHorizontal();
|
builder.Groups.Remove(group);
|
||||||
|
break;
|
||||||
group.OptionBundle = EditorGUILayout.Toggle($"可选下载包", group.OptionBundle);
|
}
|
||||||
group.InstallReady = EditorGUILayout.Toggle($"跟随主包", group.InstallReady);
|
GUI.color = groupDeleteColor;
|
||||||
|
}
|
||||||
//buildMode
|
EditorGUILayout.EndHorizontal();
|
||||||
EditorGUILayout.BeginHorizontal();
|
|
||||||
{
|
group.OptionBundle = EditorGUILayout.Toggle($"可选下载包", group.OptionBundle);
|
||||||
var EnumType = typeof(BuildEntity.EnumBuildMode);
|
group.InstallReady = EditorGUILayout.Toggle($"跟随主包", group.InstallReady);
|
||||||
var values = Enum.GetValues(EnumType);
|
|
||||||
foreach (BuildEntity.EnumBuildMode modeValue in values)
|
//buildMode
|
||||||
{
|
EditorGUILayout.BeginHorizontal();
|
||||||
var modeName = Enum.GetName(EnumType, modeValue);
|
{
|
||||||
|
var EnumType = typeof(BuildEntity.EnumBuildMode);
|
||||||
var tempColor = GUI.color;
|
var values = Enum.GetValues(EnumType);
|
||||||
if (modeValue == group.BuildMode) GUI.color = Color.green;
|
foreach (BuildEntity.EnumBuildMode modeValue in values)
|
||||||
else GUI.color = Color.white;
|
{
|
||||||
if (GUILayout.Button(new GUIContent(modeName, GetDescrib(modeValue))))
|
var modeName = Enum.GetName(EnumType, modeValue);
|
||||||
{
|
|
||||||
group.BuildMode = modeValue;
|
var tempColor = GUI.color;
|
||||||
}
|
if (modeValue == group.BuildMode) GUI.color = Color.green;
|
||||||
GUI.color = tempColor;
|
else GUI.color = Color.white;
|
||||||
}
|
if (GUILayout.Button(new GUIContent(modeName, GetDescrib(modeValue))))
|
||||||
}
|
{
|
||||||
EditorGUILayout.EndHorizontal();
|
group.BuildMode = modeValue;
|
||||||
|
}
|
||||||
EditorGUILayout.BeginVertical(new GUIStyle { padding = new RectOffset(5, 5, 5, 5) });
|
GUI.color = tempColor;
|
||||||
{
|
}
|
||||||
for (int i = 0; i < group.FolderList.Count; i++)
|
}
|
||||||
{
|
EditorGUILayout.EndHorizontal();
|
||||||
EditorGUILayout.BeginHorizontal();
|
|
||||||
{
|
EditorGUILayout.BeginVertical(new GUIStyle { padding = new RectOffset(5, 5, 5, 5) });
|
||||||
var foldAsset = group.FolderList[i];
|
{
|
||||||
var deleteColor = GUI.color;
|
for (int i = 0; i < group.FolderList.Count; i++)
|
||||||
GUI.color = Color.red;
|
{
|
||||||
if (GUILayout.Button("-", GUILayout.Width(20)))
|
EditorGUILayout.BeginHorizontal();
|
||||||
{
|
{
|
||||||
group.FolderList.RemoveAt(i);
|
var foldAsset = group.FolderList[i];
|
||||||
break;
|
var deleteColor = GUI.color;
|
||||||
}
|
GUI.color = Color.red;
|
||||||
GUI.color = deleteColor;
|
if (GUILayout.Button("-", GUILayout.Width(20)))
|
||||||
group.FolderList[i] = (DefaultAsset)EditorGUILayout.ObjectField(foldAsset, typeof(DefaultAsset), false);
|
{
|
||||||
}
|
group.FolderList.RemoveAt(i);
|
||||||
EditorGUILayout.EndHorizontal();
|
break;
|
||||||
}
|
}
|
||||||
|
GUI.color = deleteColor;
|
||||||
//draw add Folder
|
group.FolderList[i] = (DefaultAsset)EditorGUILayout.ObjectField(foldAsset, typeof(DefaultAsset), false);
|
||||||
var addFolderColor = GUI.color;
|
}
|
||||||
GUI.color = Color.yellow;
|
EditorGUILayout.EndHorizontal();
|
||||||
if (GUILayout.Button("添加资源目录"))
|
}
|
||||||
{
|
|
||||||
group.FolderList.Add(null);
|
//draw add Folder
|
||||||
}
|
var addFolderColor = GUI.color;
|
||||||
GUI.color = addFolderColor;
|
GUI.color = Color.yellow;
|
||||||
}
|
if (GUILayout.Button("添加资源目录"))
|
||||||
EditorGUILayout.EndVertical();
|
{
|
||||||
|
group.FolderList.Add(null);
|
||||||
}
|
}
|
||||||
EditorGUILayout.EndVertical();
|
GUI.color = addFolderColor;
|
||||||
GUI.color = temp;
|
}
|
||||||
}
|
EditorGUILayout.EndVertical();
|
||||||
|
|
||||||
//Draw Add Group Button
|
}
|
||||||
var addColor = GUI.color;
|
EditorGUILayout.EndVertical();
|
||||||
GUI.color = Color.yellow;
|
GUI.color = temp;
|
||||||
if (GUILayout.Button("添加组"))
|
}
|
||||||
{
|
|
||||||
builder.Groups.Add(new BuildEntity());
|
//Draw Add Group Button
|
||||||
}
|
var addColor = GUI.color;
|
||||||
GUI.color = addColor;
|
GUI.color = Color.yellow;
|
||||||
|
if (GUILayout.Button("添加组"))
|
||||||
EditorGUILayout.EndVertical();
|
{
|
||||||
|
builder.Groups.Add(new BuildEntity());
|
||||||
if (GUI.changed)
|
}
|
||||||
{
|
GUI.color = addColor;
|
||||||
MarkInBundleFiles.RefreshProjectBundleMark();
|
|
||||||
EditorUtility.SetDirty(target);
|
EditorGUILayout.EndVertical();
|
||||||
}
|
|
||||||
|
if (GUI.changed)
|
||||||
Color GetGroupColor(BuildEntity group, out string errorMsg)
|
{
|
||||||
{
|
MarkInBundleFiles.RefreshProjectBundleMark();
|
||||||
errorMsg = null;
|
EditorUtility.SetDirty(target);
|
||||||
|
}
|
||||||
if (string.IsNullOrWhiteSpace(group.GroupName))
|
|
||||||
{
|
Color GetGroupColor(BuildEntity group, out string errorMsg)
|
||||||
errorMsg = "非法名称";
|
{
|
||||||
return Color.red;
|
errorMsg = null;
|
||||||
}
|
|
||||||
if (builder.Groups.Count(item => item.GroupName == group.GroupName) > 1)
|
if (string.IsNullOrWhiteSpace(group.GroupName))
|
||||||
{
|
{
|
||||||
errorMsg = "名称重复";
|
errorMsg = "非法名称";
|
||||||
return Color.red;
|
return Color.red;
|
||||||
}
|
}
|
||||||
if (group.FolderList.Count == 0)
|
if (builder.Groups.Count(item => item.GroupName == group.GroupName) > 1)
|
||||||
{
|
{
|
||||||
errorMsg = "未包含任何目录";
|
errorMsg = "名称重复";
|
||||||
return Color.red;
|
return Color.red;
|
||||||
}
|
}
|
||||||
if (group.FolderList.Count(f => f == null) > 0)
|
if (group.FolderList.Count == 0)
|
||||||
{
|
{
|
||||||
errorMsg = "存在无效目录";
|
errorMsg = "未包含任何目录";
|
||||||
return Color.red;
|
return Color.red;
|
||||||
}
|
}
|
||||||
|
if (group.FolderList.Count(f => f == null) > 0)
|
||||||
if (group.OptionBundle) return Color.cyan;
|
{
|
||||||
|
errorMsg = "存在无效目录";
|
||||||
return Color.white;
|
return Color.red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (group.OptionBundle) return Color.cyan;
|
||||||
|
|
||||||
|
return Color.white;
|
||||||
|
}
|
||||||
|
|
||||||
string GetDescrib<T>(T value) where T : Enum
|
string GetDescrib<T>(T value) where T : Enum
|
||||||
{
|
{
|
||||||
var enumType = typeof(T);
|
var enumType = typeof(T);
|
||||||
var desAtt = enumType.GetField(value.ToString()).GetCustomAttribute<DescriptionAttribute>();
|
var desAtt = enumType.GetField(value.ToString()).GetCustomAttribute<DescriptionAttribute>();
|
||||||
return desAtt != null ? desAtt.Description : value.ToString();
|
return desAtt != null ? desAtt.Description : value.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawCompareResult(List<BundleCompare> compareResult, Dictionary<string, BundleExtraInfo> bundleExtraInfo)
|
private void DrawCompareResult(List<BundleCompare> compareResult, Dictionary<string, BundleExtraInfo> bundleExtraInfo)
|
||||||
{
|
{
|
||||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||||
foreach (var item in compareResult.OrderBy(c => c.Result))
|
foreach (var item in compareResult.OrderBy(c => c.Result))
|
||||||
{
|
{
|
||||||
if (item.Result == BundleCompare.EnumCompare.Same) continue;
|
if (item.Result == BundleCompare.EnumCompare.Same) continue;
|
||||||
EditorGUILayout.BeginHorizontal();
|
EditorGUILayout.BeginHorizontal();
|
||||||
string drawStr = null;
|
string drawStr = null;
|
||||||
Color drawColor = Color.white;
|
Color drawColor = Color.white;
|
||||||
|
|
||||||
switch (item.Result)
|
switch (item.Result)
|
||||||
{
|
{
|
||||||
case BundleCompare.EnumCompare.Same:
|
case BundleCompare.EnumCompare.Same:
|
||||||
drawStr = "=";
|
drawStr = "=";
|
||||||
drawColor = Color.black;
|
drawColor = Color.black;
|
||||||
break;
|
break;
|
||||||
case BundleCompare.EnumCompare.Modified:
|
case BundleCompare.EnumCompare.Modified:
|
||||||
drawColor = Color.yellow;
|
drawColor = Color.yellow;
|
||||||
drawStr = "*";
|
drawStr = "*";
|
||||||
break;
|
break;
|
||||||
case BundleCompare.EnumCompare.Add:
|
case BundleCompare.EnumCompare.Add:
|
||||||
drawColor = Color.green;
|
drawColor = Color.green;
|
||||||
drawStr = "+";
|
drawStr = "+";
|
||||||
break;
|
break;
|
||||||
case BundleCompare.EnumCompare.Delete:
|
case BundleCompare.EnumCompare.Delete:
|
||||||
drawColor = Color.red;
|
drawColor = Color.red;
|
||||||
drawStr = "-";
|
drawStr = "-";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawStr += item.ToString();
|
drawStr += item.ToString();
|
||||||
|
|
||||||
var temp = GUI.color;
|
var temp = GUI.color;
|
||||||
GUI.color = drawColor;
|
GUI.color = drawColor;
|
||||||
EditorGUILayout.LabelField($"{drawStr}");
|
EditorGUILayout.LabelField($"{drawStr}");
|
||||||
EditorGUILayout.EndHorizontal();
|
EditorGUILayout.EndHorizontal();
|
||||||
GUI.color = temp;
|
GUI.color = temp;
|
||||||
}
|
}
|
||||||
EditorGUILayout.EndVertical();
|
EditorGUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (BundleManifest remoteVersion, string updateVersion) FetchRemoteVersion(BuilderConfig builder)
|
public static (BundleManifest remoteVersion, string updateVersion) FetchRemoteVersion(BuilderConfig builder)
|
||||||
{
|
{
|
||||||
BundleManifest remoteVersion = null;
|
BundleManifest remoteVersion = null;
|
||||||
string updateVersion = null;
|
string updateVersion = null;
|
||||||
|
|
||||||
var bc = builder;
|
var bc = builder;
|
||||||
var patchLoader = bc.GetPatchLoader();
|
var patchLoader = bc.GetPatchLoader();
|
||||||
|
|
||||||
var remoteManifestData = patchLoader.DownloadFile($"Bundles/{VersionFlowX.PlatformFoldName}/PatchManifest.json");
|
var remoteManifestData = patchLoader.DownloadFile($"Bundles/{VersionFlowX.PlatformFoldName}/PatchManifest.json");
|
||||||
if (remoteManifestData == null)
|
if (remoteManifestData == null)
|
||||||
{
|
{
|
||||||
remoteVersion = new BundleManifest();
|
remoteVersion = new BundleManifest();
|
||||||
remoteVersion.Version = "N/A";
|
remoteVersion.Version = "N/A";
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
updateVersion = $"1.0.0.{now.Year:00}{now.Month:00}{now.Day:00}{now.Hour:00}{now.Minute:00}{now.Second:00}";
|
updateVersion = $"1.0.0.{now.Year:00}{now.Month:00}{now.Day:00}{now.Hour:00}{now.Minute:00}{now.Second:00}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var remoteJson = Encoding.ASCII.GetString(remoteManifestData);
|
var remoteJson = Encoding.ASCII.GetString(remoteManifestData);
|
||||||
var remoteManifest = BundleManifest.FromJson(remoteJson);
|
var remoteManifest = BundleManifest.FromJson(remoteJson);
|
||||||
remoteVersion = remoteManifest;
|
remoteVersion = remoteManifest;
|
||||||
var temp = remoteVersion.Version.Substring(0, remoteVersion.Version.LastIndexOf('.'));
|
var temp = remoteVersion.Version.Substring(0, remoteVersion.Version.LastIndexOf('.'));
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
updateVersion = $"{temp}.{now.Year:00}{now.Month:00}{now.Day:00}{now.Hour:00}{now.Minute:00}{now.Second:00}";
|
updateVersion = $"{temp}.{now.Year:00}{now.Month:00}{now.Day:00}{now.Hour:00}{now.Minute:00}{now.Second:00}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return (remoteVersion, updateVersion);
|
return (remoteVersion, updateVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StartUpLoad(List<BundleCompare> compareResult, BundleManifest localManifest, string outputPath, PatchUploader uploader)
|
public static void StartUpLoad(List<BundleCompare> compareResult, BundleManifest localManifest, string outputPath, PatchUploader uploader)
|
||||||
{
|
{
|
||||||
List<Bundle> bundlesToUpload = new List<Bundle>();
|
List<Bundle> bundlesToUpload = new List<Bundle>();
|
||||||
List<Bundle> bundlesToDelete = new List<Bundle>();
|
List<Bundle> bundlesToDelete = new List<Bundle>();
|
||||||
foreach (var item in compareResult)
|
foreach (var item in compareResult)
|
||||||
{
|
{
|
||||||
if (item.Result == BundleCompare.EnumCompare.Same) continue;
|
if (item.Result == BundleCompare.EnumCompare.Same) continue;
|
||||||
|
|
||||||
if (item.Result == BundleCompare.EnumCompare.Delete)
|
if (item.Result == BundleCompare.EnumCompare.Delete)
|
||||||
{
|
{
|
||||||
bundlesToDelete.Add(item.Old);
|
bundlesToDelete.Add(item.Old);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bundlesToUpload.Add(item.New);
|
bundlesToUpload.Add(item.New);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var tips = "****!!!确认上传信息!!!*****\n";
|
var tips = "****!!!确认上传信息!!!*****\n";
|
||||||
|
|
||||||
if (bundlesToUpload.Count == 0 && bundlesToDelete.Count == 0)
|
if (bundlesToUpload.Count == 0 && bundlesToDelete.Count == 0)
|
||||||
{
|
{
|
||||||
bool confirm = EditorUtility.DisplayDialog("FBI WARNING", $"CDN上没有需要更新的Bundle,将只更新版本号\n{tips}", "ok", "cancel");
|
bool confirm = EditorUtility.DisplayDialog("FBI WARNING", $"CDN上没有需要更新的Bundle,将只更新版本号\n{tips}", "ok", "cancel");
|
||||||
if (confirm)
|
if (confirm)
|
||||||
{
|
{
|
||||||
var newVersionFile = new MemoryStream(Encoding.ASCII.GetBytes(localManifest.ToJson()));
|
var newVersionFile = new MemoryStream(Encoding.ASCII.GetBytes(localManifest.ToJson()));
|
||||||
uploader.UploadFile($"Bundles/{VersionFlowX.PlatformFoldName}/PatchManifest.json", newVersionFile);
|
uploader.UploadFile($"Bundles/{VersionFlowX.PlatformFoldName}/PatchManifest.json", newVersionFile);
|
||||||
var cdnPerformer = uploader as ICDNPerformer;
|
var cdnPerformer = uploader as ICDNPerformer;
|
||||||
cdnPerformer?.CDNRefresh(new string[] { "PatchManifest.json" });
|
cdnPerformer?.CDNRefresh(new string[] { "PatchManifest.json" });
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var totalSize = bundlesToUpload.Sum(b => b.Size);
|
var totalSize = bundlesToUpload.Sum(b => b.Size);
|
||||||
var totalSizeStr = $"{totalSize}b";
|
var totalSizeStr = $"{totalSize}b";
|
||||||
if (totalSize > 1024 * 1024)
|
if (totalSize > 1024 * 1024)
|
||||||
{
|
{
|
||||||
totalSizeStr = $"{totalSize / 1024f / 1024f:.00}mb";
|
totalSizeStr = $"{totalSize / 1024f / 1024f:.00}mb";
|
||||||
}
|
}
|
||||||
else if (totalSize > 1024)
|
else if (totalSize > 1024)
|
||||||
{
|
{
|
||||||
totalSizeStr = $"{totalSize / 1024f:.00}kb";
|
totalSizeStr = $"{totalSize / 1024f:.00}kb";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool res = EditorUtility.DisplayDialog("FBI WARNING", $"本次需上传{bundlesToUpload.Count}个Bundle\n总大小为{totalSizeStr}\n{tips}", "ok", "cancel");
|
bool res = EditorUtility.DisplayDialog("FBI WARNING", $"本次需上传{bundlesToUpload.Count}个Bundle\n总大小为{totalSizeStr}\n{tips}", "ok", "cancel");
|
||||||
if (!res) return;
|
if (!res) return;
|
||||||
|
|
||||||
int max = bundlesToUpload.Count + 1;
|
int max = bundlesToUpload.Count + 1;
|
||||||
int step = 0;
|
int step = 0;
|
||||||
foreach (var bundle in bundlesToUpload)
|
foreach (var bundle in bundlesToUpload)
|
||||||
{
|
{
|
||||||
EditorUtility.DisplayProgressBar("上传", $"{bundle.BundleName}", step * 1f / max);
|
EditorUtility.DisplayProgressBar("上传", $"{bundle.BundleName}", step * 1f / max);
|
||||||
var bundleFilePath = $"{outputPath}/{bundle.BundleName}";
|
var bundleFilePath = $"{outputPath}/{bundle.BundleName}";
|
||||||
string remoteFilePath = null;
|
string remoteFilePath = null;
|
||||||
@ -410,100 +415,100 @@ namespace VersionFlow.Editors
|
|||||||
|
|
||||||
remoteFilePath = $"Bundles/{VersionFlowX.PlatformFoldName}/{fileName}.{bundle.Hash}{ext}";
|
remoteFilePath = $"Bundles/{VersionFlowX.PlatformFoldName}/{fileName}.{bundle.Hash}{ext}";
|
||||||
|
|
||||||
uploader.UploadFile(remoteFilePath, fileSt);
|
uploader.UploadFile(remoteFilePath, fileSt);
|
||||||
|
|
||||||
step++;
|
step++;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorUtility.DisplayProgressBar("上传", $"上传PatchManifest.json", step * 1f / max);
|
EditorUtility.DisplayProgressBar("上传", $"上传PatchManifest.json", step * 1f / max);
|
||||||
var st = new MemoryStream(Encoding.ASCII.GetBytes(localManifest.ToJson()));
|
var st = new MemoryStream(Encoding.ASCII.GetBytes(localManifest.ToJson()));
|
||||||
uploader.UploadFile($"Bundles/{VersionFlowX.PlatformFoldName}/PatchManifest.json", st);
|
uploader.UploadFile($"Bundles/{VersionFlowX.PlatformFoldName}/PatchManifest.json", st);
|
||||||
(uploader as ICDNPerformer)?.CDNRefresh(new string[] { $"Bundles/{VersionFlowX.PlatformFoldName}/PatchManifest.json" });
|
(uploader as ICDNPerformer)?.CDNRefresh(new string[] { $"Bundles/{VersionFlowX.PlatformFoldName}/PatchManifest.json" });
|
||||||
|
|
||||||
if (bundlesToDelete.Count > 0)
|
if (bundlesToDelete.Count > 0)
|
||||||
{
|
{
|
||||||
max = bundlesToDelete.Count + 1;
|
max = bundlesToDelete.Count + 1;
|
||||||
step = 0;
|
step = 0;
|
||||||
foreach (var bundle in bundlesToDelete)
|
foreach (var bundle in bundlesToDelete)
|
||||||
{
|
{
|
||||||
EditorUtility.DisplayProgressBar("移除冗余bundle", $"{bundle.BundleName}", step * 1f / max);
|
EditorUtility.DisplayProgressBar("移除冗余bundle", $"{bundle.BundleName}", step * 1f / max);
|
||||||
|
|
||||||
var temp = Path.GetFileNameWithoutExtension(bundle.BundleName);
|
var temp = Path.GetFileNameWithoutExtension(bundle.BundleName);
|
||||||
var ext = Path.GetExtension(bundle.BundleName);
|
var ext = Path.GetExtension(bundle.BundleName);
|
||||||
string bundlePath = $"Bundles/{VersionFlowX.PlatformFoldName}/{temp}.{bundle.Hash}{ext}";
|
string bundlePath = $"Bundles/{VersionFlowX.PlatformFoldName}/{temp}.{bundle.Hash}{ext}";
|
||||||
uploader.DeleteFile(bundlePath);
|
uploader.DeleteFile(bundlePath);
|
||||||
step++;
|
step++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorUtility.ClearProgressBar();
|
EditorUtility.ClearProgressBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CalcBundleHash(string bundleOutputPath, List<AssetBundleBuild> buildInfoList, Dictionary<string, BundleExtraInfo> bundleExtraInfo, AssetBundleManifest report)
|
public static void CalcBundleHash(string bundleOutputPath, List<AssetBundleBuild> buildInfoList, Dictionary<string, BundleExtraInfo> bundleExtraInfo, AssetBundleManifest report)
|
||||||
{
|
{
|
||||||
var bundleNames = report.GetAllAssetBundles();
|
var bundleNames = report.GetAllAssetBundles();
|
||||||
int total = bundleNames.Length;
|
int total = bundleNames.Length;
|
||||||
|
|
||||||
int step = 0;
|
int step = 0;
|
||||||
foreach (var bundleName in bundleNames)
|
foreach (var bundleName in bundleNames)
|
||||||
{
|
{
|
||||||
var hash = report.GetAssetBundleHash(bundleName);
|
var hash = report.GetAssetBundleHash(bundleName);
|
||||||
bundleExtraInfo[bundleName].BundleHash = hash;
|
bundleExtraInfo[bundleName].BundleHash = hash;
|
||||||
|
|
||||||
step++;
|
step++;
|
||||||
|
|
||||||
EditorUtility.DisplayProgressBar("算hash", $"{step}/{total}", step / total * 1f);
|
EditorUtility.DisplayProgressBar("算hash", $"{step}/{total}", step / total * 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorUtility.ClearProgressBar();
|
EditorUtility.ClearProgressBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetInstallBundles(BuilderConfig builder, bool force)
|
public static void SetInstallBundles(BuilderConfig builder, bool force)
|
||||||
{
|
{
|
||||||
if (Directory.Exists($"{Application.streamingAssetsPath}/Bundles"))
|
if (Directory.Exists($"{Application.streamingAssetsPath}/Bundles"))
|
||||||
Directory.Delete($"{Application.streamingAssetsPath}/Bundles", true);
|
Directory.Delete($"{Application.streamingAssetsPath}/Bundles", true);
|
||||||
|
|
||||||
//获取oss上的bundle清单
|
//获取oss上的bundle清单
|
||||||
var remoteInfo = FetchRemoteVersion(builder);
|
var remoteInfo = FetchRemoteVersion(builder);
|
||||||
|
|
||||||
//收集定义为随包资源的bundle
|
//收集定义为随包资源的bundle
|
||||||
List<Bundle> installBundles = new List<Bundle>();
|
List<Bundle> installBundles = new List<Bundle>();
|
||||||
foreach (var bundle in remoteInfo.remoteVersion.Bundles)
|
foreach (var bundle in remoteInfo.remoteVersion.Bundles)
|
||||||
{
|
{
|
||||||
if (force) installBundles.Add(bundle);
|
if (force) installBundles.Add(bundle);
|
||||||
else if (bundle.InstallBundle) installBundles.Add(bundle);
|
else if (bundle.InstallBundle) installBundles.Add(bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (installBundles.Count > 0)
|
if (installBundles.Count > 0)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory($"{Application.streamingAssetsPath}/Bundles");
|
Directory.CreateDirectory($"{Application.streamingAssetsPath}/Bundles");
|
||||||
BundleManifest installManifest = new BundleManifest();
|
BundleManifest installManifest = new BundleManifest();
|
||||||
installManifest.Version = remoteInfo.remoteVersion.Version;
|
installManifest.Version = remoteInfo.remoteVersion.Version;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
var patchLoader = builder.GetPatchLoader();
|
var patchLoader = builder.GetPatchLoader();
|
||||||
|
|
||||||
foreach (var bundle in installBundles)
|
foreach (var bundle in installBundles)
|
||||||
{
|
{
|
||||||
EditorUtility.DisplayProgressBar("处理随包资源", $"{bundle.BundleName}", i * 1f / installBundles.Count);
|
EditorUtility.DisplayProgressBar("处理随包资源", $"{bundle.BundleName}", i * 1f / installBundles.Count);
|
||||||
|
|
||||||
var ext = Path.GetExtension(bundle.BundleName);
|
var ext = Path.GetExtension(bundle.BundleName);
|
||||||
var fileName = Path.GetFileNameWithoutExtension(bundle.BundleName);
|
var fileName = Path.GetFileNameWithoutExtension(bundle.BundleName);
|
||||||
var fileNameInOSS = $"{fileName}.{bundle.Hash}{ext}";
|
var fileNameInOSS = $"{fileName}.{bundle.Hash}{ext}";
|
||||||
|
|
||||||
var bundleData = patchLoader.DownloadFile($"Bundles/{VersionFlowX.PlatformFoldName}/{fileNameInOSS}");
|
var bundleData = patchLoader.DownloadFile($"Bundles/{VersionFlowX.PlatformFoldName}/{fileNameInOSS}");
|
||||||
|
|
||||||
File.WriteAllBytes($"{Application.streamingAssetsPath}/Bundles/{bundle.BundleName}", bundleData);
|
File.WriteAllBytes($"{Application.streamingAssetsPath}/Bundles/{bundle.BundleName}", bundleData);
|
||||||
installManifest.UpdateBundleData(bundle);
|
installManifest.UpdateBundleData(bundle);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
File.WriteAllText($"{Application.streamingAssetsPath}/Bundles/InstallPatchManifest.json", installManifest.ToJson());
|
File.WriteAllText($"{Application.streamingAssetsPath}/Bundles/InstallPatchManifest.json", installManifest.ToJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorUtility.ClearProgressBar();
|
EditorUtility.ClearProgressBar();
|
||||||
|
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
93
Assets/VersionFlow/Editor/MsgBool.cs
Normal file
93
Assets/VersionFlow/Editor/MsgBool.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
namespace VersionFlow.Editors
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// String和Bool的缝合怪
|
||||||
|
/// </summary>
|
||||||
|
public struct MsgBool
|
||||||
|
{
|
||||||
|
public string ErrorMsg;
|
||||||
|
public bool Value;
|
||||||
|
|
||||||
|
public override readonly string ToString()
|
||||||
|
{
|
||||||
|
if (Value)
|
||||||
|
{
|
||||||
|
return true.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ErrorMsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator MsgBool(string errorMsg)
|
||||||
|
{
|
||||||
|
return new MsgBool { Value = false, ErrorMsg = errorMsg };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator MsgBool(bool value)
|
||||||
|
{
|
||||||
|
return new MsgBool { Value = value };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator bool(MsgBool msgBool)
|
||||||
|
{
|
||||||
|
return msgBool.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator (bool, string)(MsgBool msgBool)
|
||||||
|
{
|
||||||
|
return (msgBool.Value, msgBool.ErrorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator string(MsgBool msgBool)
|
||||||
|
{
|
||||||
|
return msgBool.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct MsgBool<T>
|
||||||
|
{
|
||||||
|
public string ErrorMsg;
|
||||||
|
public bool Value;
|
||||||
|
public T Result;
|
||||||
|
|
||||||
|
public override readonly string ToString()
|
||||||
|
{
|
||||||
|
if (Value)
|
||||||
|
{
|
||||||
|
if (Result != null) return Result.ToString();
|
||||||
|
return true.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ErrorMsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator MsgBool<T>(string errorMsg)
|
||||||
|
{
|
||||||
|
return new MsgBool<T> { Value = false, ErrorMsg = errorMsg };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator MsgBool<T>(bool value)
|
||||||
|
{
|
||||||
|
return new MsgBool<T> { Value = value };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator MsgBool<T>(T result)
|
||||||
|
{
|
||||||
|
return new MsgBool<T> { Value = true, Result = result };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator bool(MsgBool<T> msgBool)
|
||||||
|
{
|
||||||
|
return msgBool.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator string(MsgBool<T> msgBool)
|
||||||
|
{
|
||||||
|
return msgBool.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/VersionFlow/Editor/MsgBool.cs.meta
Normal file
11
Assets/VersionFlow/Editor/MsgBool.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d23328d75cc93354ea1a595833f504a2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -7,6 +7,7 @@ namespace VersionFlow.Editors
|
|||||||
{
|
{
|
||||||
public abstract class PatchUploader : ScriptableObject
|
public abstract class PatchUploader : ScriptableObject
|
||||||
{
|
{
|
||||||
|
public abstract MsgBool Status { get; }
|
||||||
public PatchUploader() { }
|
public PatchUploader() { }
|
||||||
public abstract void CfgChanged(BuilderConfig builder, string cfgJson);
|
public abstract void CfgChanged(BuilderConfig builder, string cfgJson);
|
||||||
public abstract void UploadFile(string remoteFilePath, MemoryStream localfileStream);
|
public abstract void UploadFile(string remoteFilePath, MemoryStream localfileStream);
|
||||||
@ -21,17 +22,20 @@ namespace VersionFlow.Editors
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
protected CONFIG m_cfg;
|
protected CONFIG m_cfg;
|
||||||
|
|
||||||
|
MsgBool m_status;
|
||||||
|
public override MsgBool Status => m_status;
|
||||||
|
|
||||||
public sealed override void CfgChanged(BuilderConfig builder, string cfgJson)
|
public sealed override void CfgChanged(BuilderConfig builder, string cfgJson)
|
||||||
{
|
{
|
||||||
m_builder = builder;
|
m_builder = builder;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_cfg = JsonUtility.FromJson<CONFIG>(cfgJson);
|
m_cfg = JsonUtility.FromJson<CONFIG>(cfgJson);
|
||||||
OnCfgChanged();
|
m_status = OnCfgChanged();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.LogError(ex);
|
m_status = ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +44,6 @@ namespace VersionFlow.Editors
|
|||||||
return JsonUtility.ToJson(m_cfg);
|
return JsonUtility.ToJson(m_cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void OnCfgChanged();
|
protected abstract MsgBool OnCfgChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,17 +23,20 @@ namespace VersionFlow.Editors
|
|||||||
private OssClient m_ossClient;
|
private OssClient m_ossClient;
|
||||||
private Client m_cdnClient;
|
private Client m_cdnClient;
|
||||||
|
|
||||||
protected override void OnCfgChanged()
|
protected override MsgBool OnCfgChanged()
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(m_cfg.BucketName)) return "BucketName无效";
|
||||||
|
if (string.IsNullOrWhiteSpace(m_cfg.UploadPath)) return "UploadPath无效";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_ossClient = new OssClient(m_cfg.endPoint, m_cfg.accessKeyId, m_cfg.accessKeySecret);
|
m_ossClient = new OssClient(m_cfg.endPoint, m_cfg.accessKeyId, m_cfg.accessKeySecret);
|
||||||
m_cdnClient = new Client(new AlibabaCloud.OpenApiClient.Models.Config { AccessKeyId = m_cfg.accessKeyId, AccessKeySecret = m_cfg.accessKeySecret });
|
m_cdnClient = new Client(new AlibabaCloud.OpenApiClient.Models.Config { AccessKeyId = m_cfg.accessKeyId, AccessKeySecret = m_cfg.accessKeySecret });
|
||||||
Debug.Log("AliOSS SDK 初始化成功");
|
return true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Debug.LogError("AliOSS SDK 初始化失败,请检查相关参数配置");
|
return "AliOSS SDK 初始化失败,请检查相关参数配置";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,10 @@ namespace VersionFlow.Editors
|
|||||||
[Description("本地文件系统")]
|
[Description("本地文件系统")]
|
||||||
public class PatchUploader_LocalFileSystem : PatchUploader<PatchUploader_LocalFileSystem.Config>, IAsyncDownloader
|
public class PatchUploader_LocalFileSystem : PatchUploader<PatchUploader_LocalFileSystem.Config>, IAsyncDownloader
|
||||||
{
|
{
|
||||||
protected override void OnCfgChanged() { }
|
protected override MsgBool OnCfgChanged()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public override void UploadFile(string remoteFilePath, MemoryStream localfileStream)
|
public override void UploadFile(string remoteFilePath, MemoryStream localfileStream)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using UnityEditor;
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VersionFlow.Runtime;
|
using VersionFlow.Runtime;
|
||||||
|
|
||||||
@ -32,23 +33,42 @@ namespace VersionFlow.Editors
|
|||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
{
|
{
|
||||||
EditorGUILayout.BeginHorizontal();
|
EditorGUILayout.BeginHorizontal();
|
||||||
if (GUILayout.Toggle(m_currentEditor == m_builderEditor, "上传设置", GUI.skin.button))
|
|
||||||
{
|
{
|
||||||
m_currentEditor = m_builderEditor;
|
EditorGUILayout.BeginVertical(GUILayout.Width(200));
|
||||||
}
|
{
|
||||||
if (GUILayout.Toggle(m_currentEditor == m_settingEditor, "运行时设置", GUI.skin.button))
|
DrawEditorTabRegion();
|
||||||
{
|
}
|
||||||
m_currentEditor = m_settingEditor;
|
EditorGUILayout.EndVertical();
|
||||||
}
|
|
||||||
EditorGUILayout.EndVertical();
|
|
||||||
|
|
||||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||||
{
|
{
|
||||||
m_builderEditorScroll = EditorGUILayout.BeginScrollView(m_builderEditorScroll);
|
m_builderEditorScroll = EditorGUILayout.BeginScrollView(m_builderEditorScroll);
|
||||||
m_currentEditor.OnInspectorGUI();
|
DrawSelectEditor();
|
||||||
EditorGUILayout.EndScrollView();
|
EditorGUILayout.EndScrollView();
|
||||||
|
}
|
||||||
|
EditorGUILayout.EndVertical();
|
||||||
|
}
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawSelectEditor()
|
||||||
|
{
|
||||||
|
m_currentEditor.OnInspectorGUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawEditorTabRegion()
|
||||||
|
{
|
||||||
|
DrawEditorTabItem(m_builderEditor, "上传设置");
|
||||||
|
DrawEditorTabItem(m_settingEditor, "运行时设置");
|
||||||
|
|
||||||
|
void DrawEditorTabItem(Editor targetEditor, string name)
|
||||||
|
{
|
||||||
|
if (GUILayout.Toggle(m_currentEditor == targetEditor, name, new GUIStyle(GUI.skin.button) { margin = new RectOffset() }, GUILayout.Height(40)))
|
||||||
|
{
|
||||||
|
m_currentEditor = targetEditor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EditorGUILayout.EndVertical();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user