浏览代码

Handle Screen Capture Module

/refactor-handle-modules
Thomas ICHÉ 3 年前
当前提交
a824810e
共有 3 个文件被更改,包括 19 次插入0 次删除
  1. 5
      Runtime/GameplayIngredients.asmdef
  2. 7
      Runtime/LevelScripting/Actions/TakeScreenshotAction.cs
  3. 7
      Runtime/Managers/Implementations/ScreenshotManager.cs

5
Runtime/GameplayIngredients.asmdef


"name": "com.unity.modules.physics2d",
"expression": "1.0.0",
"define": "MODULE_PHYSICS2D"
},
{
"name": "com.unity.modules.screencapture",
"expression": "1.0.0",
"define": "MODULE_SCREENCAPTURE"
}
],
"noEngineReferences": false

7
Runtime/LevelScripting/Actions/TakeScreenshotAction.cs


namespace GameplayIngredients.Actions
{
#if !MODULE_SCREENCAPTURE
[WarnDisabledModule("Screen Capture")]
#endif
[AddComponentMenu(ComponentMenu.actionsPath + "Take Screenshot Action")]
[Callable("Screen", "Actions/ic-action-screen.png")]
public class TakeScreenshotAction : ActionBase

public override void Execute(GameObject instigator = null)
{
#if MODULE_SCREENCAPTURE
#else
Debug.Log("TakeScreenshotAction Cannot Take Screenshot : Unity Module Screen Capture is Disabled.");
#endif
}
public override string GetDefaultName()

7
Runtime/Managers/Implementations/ScreenshotManager.cs


namespace GameplayIngredients
{
#if !MODULE_SCREENCAPTURE
[WarnDisabledModule("Screen Capture")]
#endif
[AddComponentMenu(ComponentMenu.managersPath + "Screenshot Manager")]
[ManagerDefaultPrefab("ScreenshotManager")]
public class ScreenshotManager : Manager

{
if (Input.GetKeyDown(ScreenshotKeyCode))
{
#if MODULE_SCREENCAPTURE
var now = System.DateTime.Now;
Callable.Call(OnBeforeScreenshot);
string path = $"{Application.dataPath}/../{Prefix}-{now.Year}{now.Month}{now.Day}-{now.Hour}{now.Minute}{now.Second}{now.Millisecond}.png";

#else
Debug.Log("Screenshot Manager Cannot Take Screenshot : Unity Module Screen Capture is Disabled.");
#endif
}
}
}
正在加载...
取消
保存