Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
37 changes: 11 additions & 26 deletions Assets/CosmosEngine/Editor/CosmosEngineEditor/CBuildTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,8 @@ struct XVersionControlInfo

static int PushedAssetCount = 0;

public event Action<UnityEngine.Object, string, string> BeforeBuildAssetBundleEvent;

// 鉤子函數, 動態改變某些打包行為
public static bool HookFunc(System.Type classType, string funcName, params object[] args)
{
if (classType == null)
{
return false;
}

MethodInfo methodInfo = classType.GetMethod(funcName, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
if (methodInfo == null)
{
return false;
}

CBase.Log("HookFunc- {0}:{1}", classType.Name, funcName);
methodInfo.Invoke(null, args);

return true;
}
public static event Action<UnityEngine.Object, string, string> BeforeBuildAssetBundleEvent;
public static event Action<UnityEngine.Object, string, string> AfterBuildAssetBundleEvent;

#region 打包功能
public static string MakeSureExportPath(string path, BuildTarget buildTarget)
Expand Down Expand Up @@ -154,7 +135,11 @@ public static uint BuildAssetBundle(Object asset, string path, BuildTarget build
string relativePath = path;
path = MakeSureExportPath(path, buildTarget);

if ((prefabType == PrefabType.None && AssetDatabase.GetAssetPath(asset) == string.Empty) ||
if (asset is Texture)
{
asset = asset; // Texutre不复制拷贝一份
}
else if ((prefabType == PrefabType.None && AssetDatabase.GetAssetPath(asset) == string.Empty) ||
(prefabType == PrefabType.ModelPrefabInstance))
{
tmpObj = (GameObject)GameObject.Instantiate(asset);
Expand All @@ -166,8 +151,8 @@ public static uint BuildAssetBundle(Object asset, string path, BuildTarget build
asset = PrefabUtility.GetPrefabParent(asset);
}


HookFunc(typeof(CBuildTools), "BeforeBuildAssetBundle", asset, path, relativePath);
if (BeforeBuildAssetBundleEvent != null)
BeforeBuildAssetBundleEvent(asset, path, relativePath);

uint crc;
BuildPipeline.BuildAssetBundle(
Expand All @@ -186,8 +171,8 @@ public static uint BuildAssetBundle(Object asset, string path, BuildTarget build

CBase.Log("生成文件: {0}", path);


HookFunc(typeof(CBuildTools), "AfterBuildAssetBundle", asset, path, relativePath);
if (AfterBuildAssetBundleEvent != null)
AfterBuildAssetBundleEvent(asset, path, relativePath);

return crc;
}
Expand Down
28 changes: 22 additions & 6 deletions Assets/CosmosEngine/Editor/CosmosEngineEditor/CBuild_UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public partial class CBuild_UI : AutoBuildBase
public override string GetDirectory() { return "UI"; }
public override string GetExtention() { return "*.unity"; }

public static event Action<CBuild_UI> Custom_BeginExport;
public static event Action<CBuild_UI> BeginExportEvent;
public static event Action<CBuild_UI, string, string, GameObject> ExportCurrentUIEvent;
public static event Action ExportUIMenuEvent;
public static event Action<CBuild_UI> EndExportEvent;


public static string GetBuildRelPath(string uiName)
{
Expand All @@ -39,7 +43,12 @@ public static string GetBuildRelPath(string uiName)
public void ExportCurrentUI()
{
CreateTempPrefab();
if (!CBuildTools.HookFunc(typeof(CBuild_UI), "Custom_ExportCurrentUI", this, UIScenePath, UIName, TempPanelObject))

if (ExportCurrentUIEvent != null)
{
ExportCurrentUIEvent(this, UIScenePath, UIName, TempPanelObject);
}
else
{
CBuildTools.BuildAssetBundle(TempPanelObject, GetBuildRelPath(UIName));
}
Expand All @@ -48,7 +57,10 @@ public void ExportCurrentUI()

public override void BeginExport()
{
CBuildTools.HookFunc(typeof(CBuild_UI), "Custom_BeginExport", this);
if (BeginExportEvent != null)
{
BeginExportEvent(this);
}
}

public override void Export(string path)
Expand All @@ -65,7 +77,10 @@ public override void Export(string path)

public override void EndExport()
{
CBuildTools.HookFunc(typeof(CBuild_UI), "Custom_EndExport", this);
if (EndExportEvent != null)
{
EndExportEvent(this);
}

}

Expand Down Expand Up @@ -208,8 +223,9 @@ public static void CreateUI()
[MenuItem("CosmosEngine/UI/Export Current UI %&U")]
public static void ExportUIMenu()
{
CBuildTools.HookFunc(typeof(CBuild_UI), "Custom_ExportUIMenu");

if (ExportUIMenuEvent != null)
ExportUIMenuEvent();

CBuild_UI uiBuild = new CBuild_UI();
if (!uiBuild.CheckUI(true))
return;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions Assets/CosmosEngine/Scripts/BaseModules/UI/CUIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class CUIManager : ICModule
public Dictionary<string, CUILoadState> UIWindows = new Dictionary<string, CUILoadState>();
public bool UIRootLoaded = false;

public event System.Action<string> OpenWindowEvent;
public event System.Action<string> CloseWindowEvent;
public static event Action<CUIController> OnOpenEvent;
public static event Action<CUIController> OnCloseEvent;

private CUIManager()
{
Expand Down Expand Up @@ -164,7 +164,8 @@ void OnDynamicWindowCallback(CUIController _ui, object[] _args)
originArgs[i - 2] = _args[i];

InitWindow(_instanceUIState, uiBase, true, originArgs);
OnUIWindowLoaded(_instanceUIState, uiBase);
OnUIWindowLoadedCallbacks(_instanceUIState, uiBase);

}

public void CloseWindow(Type t)
Expand All @@ -179,9 +180,6 @@ public void CloseWindow<T>()

public void CloseWindow(string name)
{
if (CloseWindowEvent != null)
CloseWindowEvent(name);

CUILoadState uiState;
if (!UIWindows.TryGetValue(name, out uiState))
{
Expand All @@ -195,6 +193,9 @@ public void CloseWindow(string name)
}

uiState.UIWindow.gameObject.SetActive(false);

if (OnCloseEvent != null)
OnCloseEvent(uiState.UIWindow);
uiState.UIWindow.OnClose();

if (!uiState.IsStaticUI)
Expand Down Expand Up @@ -315,7 +316,7 @@ IEnumerator LoadUIAssetBundle(string path, string name, CUILoadState openState)

uiBase.UIName = uiBase.UITemplateName = openState.Name;
InitWindow(openState, uiBase, openState.OpenWhenFinish, openState.OpenArgs);
OnUIWindowLoaded(openState, uiBase);
OnUIWindowLoadedCallbacks(openState, uiBase);

}

Expand Down Expand Up @@ -382,16 +383,18 @@ public void CallUI<T>(Action<T, object[]> callback, params object[] args) where

void OnOpen(CUILoadState uiState, params object[] args)
{
if (OpenWindowEvent != null)
OpenWindowEvent(uiState.UIType);

CUIController uiBase = uiState.UIWindow;
uiBase.OnPreOpen();
if (uiBase.gameObject.activeSelf)
{
uiBase.OnClose();
}
else
uiBase.gameObject.SetActive(true);


if (OnOpenEvent != null)
OnOpenEvent(uiBase);
uiBase.OnOpen(args);
}

Expand All @@ -407,7 +410,7 @@ void InitWindow(CUILoadState uiState, CUIController uiBase, bool open, params ob
}

}
void OnUIWindowLoaded(CUILoadState uiState, CUIController uiBase)
void OnUIWindowLoadedCallbacks(CUILoadState uiState, CUIController uiBase)
{
//if (openState.OpenWhenFinish) // 加载完打开 模式下,打开时执行回调
{
Expand Down
1 change: 1 addition & 0 deletions Assets/CosmosEngine/Scripts/Bridges/CNGUIBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void CreateUIRoot()
CBase.Assert(UiRoot);
UiRoot.scalingStyle = UIRoot.Scaling.ConstrainedOnMobiles;
UiRoot.manualHeight = 1920;
UiRoot.manualWidth = 1080;

GameObject panelRootObj = new GameObject("PanelRoot");
CTool.SetChild(panelRootObj.transform, uiRootobj.transform);
Expand Down
8 changes: 8 additions & 0 deletions Assets/CosmosEngine/Scripts/Utils/CTabReader.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/CosmosEngine/Scripts/Utils/ICTabReadble.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
//------------------------------------------------------------------------------
//
// CosmosEngine - The Lightweight Unity3D Game Develop Framework
//
// Version 0.8 (20140904)
// Copyright © 2011-2014
// MrKelly <23110388@qq.com>
// https://github.com/mr-kelly/CosmosEngine
//
//------------------------------------------------------------------------------
using UnityEngine;
using System.Collections;
public class CFiber_Demo : MonoBehaviour
{
void Start()
{
CFiber.Instance.PlayCoroutine(TestCo());
}
IEnumerator TestCo()
{
yield return new WaitForSeconds(1f);
Debug.Log("Success! Wait For seconds" + Time.time);
yield return new CustomWaitForMileSeconds(3000);
Debug.Log("Success! Wait For mileseconds" + Time.time);
Debug.Log("Over TestCo");
}
}
public class CustomWaitForMileSeconds : CFiberBase
{
private int MileSeconds;
private float StartTime;
public CustomWaitForMileSeconds(int mileseconds)
{
MileSeconds = mileseconds;
StartTime = Time.time;
}
public override IEnumerator Wait()
{
float endTime = StartTime + (float)MileSeconds / 1000f;
while (Time.time < endTime)
yield return null;
}
}
//------------------------------------------------------------------------------
//
// CosmosEngine - The Lightweight Unity3D Game Develop Framework
//
// Version 0.8 (20140904)
// Copyright © 2011-2014
// MrKelly <23110388@qq.com>
// https://github.com/mr-kelly/CosmosEngine
//
//------------------------------------------------------------------------------
using UnityEngine;
using System.Collections;


public class CFiber_Demo : MonoBehaviour
{
void Start()
{
CFiber.Instance.PlayCoroutine(TestCo());
}

IEnumerator TestCo()
{
yield return new WaitForSeconds(1f);
Debug.Log("Success! Wait For seconds" + Time.time);

yield return new CustomWaitForMileSeconds(3000);
Debug.Log("Success! Wait For mileseconds" + Time.time);

Debug.Log("Over TestCo");
}
}


public class CustomWaitForMileSeconds : CFiberBase
{
private int MileSeconds;

private float StartTime;

public CustomWaitForMileSeconds(int mileseconds)
{
MileSeconds = mileseconds;
StartTime = Time.time;
}

public override IEnumerator Wait()
{
float endTime = StartTime + (float)MileSeconds / 1000f;
while (Time.time < endTime)
yield return null;
}

}
8 changes: 8 additions & 0 deletions Assets/Editor/CBuild_Audio.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions Assets/Plugins/Editor/NGUIEditor.meta

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/Product/UI/DemoHome.unity
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2082452486}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -.703812301, y: 0, z: 0}
m_LocalPosition: {x: .646900237, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1549786181}
Expand Down
12 changes: 6 additions & 6 deletions Assets/Resources/CEngineConfig.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Key Value Comment
ProductRelPath ../Product
AssetBundleRelPath StreamingAssets
AssetBundleExt .unity3d base
IsLoadAssetBundle 1
UIBridgeType NGUI
Key Value Comment
ProductRelPath ../App
AssetBundleRelPath StreamingAssets
AssetBundleExt .unity3d base
IsLoadAssetBundle 1
UIBridgeType NGUI
Binary file modified Assets/StreamingAssets/Win32/UI/DemoHome_UI.unity3d
Binary file not shown.
Binary file added Docs/structure.vsdx
Binary file not shown.
Binary file added Docs/ui_module.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/ui_module.vsdx
Binary file not shown.
Binary file added Docs/~$$ui_module.~vsdx
Binary file not shown.
Loading