mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 03:35:10 +00:00
minigame template
This commit is contained in:
parent
99bb47cf1b
commit
96af9cf90e
9 changed files with 112 additions and 12 deletions
|
@ -1,12 +1,10 @@
|
|||
using System.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
|
||||
using SatorImaging.UnitySourceGenerator.Editor;
|
||||
using HeavenStudio;
|
||||
|
||||
public class CreateAssetBundles
|
||||
{
|
||||
[MenuItem("Assets/Build AssetBundles/Current Platform")]
|
||||
|
@ -17,6 +15,8 @@ public class CreateAssetBundles
|
|||
{
|
||||
Directory.CreateDirectory(assetBundleDirectory);
|
||||
}
|
||||
AssetDatabase.Refresh();
|
||||
USGUtility.ForceGenerateByType(typeof(Minigames));
|
||||
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@ public class CreateAssetBundles
|
|||
{
|
||||
Directory.CreateDirectory(assetBundleDirectory);
|
||||
}
|
||||
AssetDatabase.Refresh();
|
||||
USGUtility.ForceGenerateByType(typeof(Minigames));
|
||||
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneWindows);
|
||||
}
|
||||
|
||||
|
@ -39,6 +41,8 @@ public class CreateAssetBundles
|
|||
{
|
||||
Directory.CreateDirectory(assetBundleDirectory);
|
||||
}
|
||||
AssetDatabase.Refresh();
|
||||
USGUtility.ForceGenerateByType(typeof(Minigames));
|
||||
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneLinux64);
|
||||
}
|
||||
|
||||
|
@ -50,6 +54,8 @@ public class CreateAssetBundles
|
|||
{
|
||||
Directory.CreateDirectory(assetBundleDirectory);
|
||||
}
|
||||
AssetDatabase.Refresh();
|
||||
USGUtility.ForceGenerateByType(typeof(Minigames));
|
||||
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneOSX);
|
||||
}
|
||||
}
|
14
Assets/Editor/CreateMinigameScriptTemplate.cs
Normal file
14
Assets/Editor/CreateMinigameScriptTemplate.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using SatorImaging.UnitySourceGenerator.Editor;
|
||||
|
||||
public class CreateMinigameScriptTemplate
|
||||
{
|
||||
[MenuItem("Assets/Heaven Studio/Create Minigame Script From Template", priority = 0)]
|
||||
public static void CreateMinigameScript()
|
||||
{
|
||||
ProjectWindowUtil.CreateScriptAssetFromTemplateFile("Assets/Editor/ScriptTemplates/MinigameScriptTemplate.txt", "NewMinigame.cs");
|
||||
AssetDatabase.Refresh();
|
||||
USGUtility.ForceGenerateByType(typeof(HeavenStudio.Minigames));
|
||||
}
|
||||
}
|
11
Assets/Editor/CreateMinigameScriptTemplate.cs.meta
Normal file
11
Assets/Editor/CreateMinigameScriptTemplate.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 24bc0d119c30f3a41aee57b4e85dbf64
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Editor/ScriptTemplates.meta
Normal file
8
Assets/Editor/ScriptTemplates.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 12ec433916efb3c4a895be2ac0dd6935
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
52
Assets/Editor/ScriptTemplates/MinigameScriptTemplate.txt
Normal file
52
Assets/Editor/ScriptTemplates/MinigameScriptTemplate.txt
Normal file
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.InputSystem;
|
||||
|
||||
using Jukebox;
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
using static Minigames;
|
||||
/// Minigame loaders handle the setup of your minigame.
|
||||
/// Here, you designate the game prefab, define entities, and mark what AssetBundle to load
|
||||
|
||||
/// Names of minigame loaders follow a specific naming convention of `PlatformcodeNameLoader`, where:
|
||||
/// `Platformcode` is a three-leter platform code with the minigame's origin
|
||||
/// `Name` is a short internal name
|
||||
/// `Loader` is the string "Loader"
|
||||
|
||||
/// Platform codes are as follows:
|
||||
/// Agb: Gameboy Advance ("Advance Gameboy")
|
||||
/// Ntr: Nintendo DS ("Nitro")
|
||||
/// Rvl: Nintendo Wii ("Revolution")
|
||||
/// Ctr: Nintendo 3DS ("Centrair")
|
||||
/// Mob: Mobile
|
||||
/// Pco: PC / Other
|
||||
|
||||
/// Fill in the loader class label, "*prefab name*", and "*Display Name*" with the relevant information
|
||||
/// For help, feel free to reach out to us on our discord, in the #development channel.
|
||||
public static class _______________
|
||||
{
|
||||
public static Minigame AddGame(EventCaller eventCaller)
|
||||
{
|
||||
return new Minigame("*prefab name*", "*Display Name*", "ffffff", false, false, new List<GameAction>()
|
||||
{
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
/// This class handles the minigame logic.
|
||||
/// Minigame inherits directly from MonoBehaviour, and adds Heaven Studio specific methods to override.
|
||||
public class #SCRIPTNAME# : Minigame
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a701bb5358c08074b991f83428d52446
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -21,7 +21,7 @@ using System.IO;
|
|||
|
||||
namespace HeavenStudio
|
||||
{
|
||||
[UnitySourceGenerator(typeof(MinigameLoaderGenerator), OverwriteIfFileExists = false)]
|
||||
[UnitySourceGenerator(typeof(MinigameLoaderGenerator), OverwriteIfFileExists = true)]
|
||||
public partial class Minigames
|
||||
{
|
||||
public enum RecommendedControlStyle
|
||||
|
|
|
@ -110,7 +110,12 @@ namespace {context.TargetClass.Namespace}
|
|||
");
|
||||
|
||||
// USG: return true to tell USG to write content into OutputPath. false to do nothing.
|
||||
return true;
|
||||
// only write if changes are made.
|
||||
if (!System.IO.File.Exists(context.OutputPath))
|
||||
return true;
|
||||
|
||||
string oldContent = System.IO.File.ReadAllText(context.OutputPath);
|
||||
return sb.ToString() != oldContent;
|
||||
}
|
||||
|
||||
#pragma warning restore IDE0051
|
||||
|
|
|
@ -18,11 +18,8 @@ MonoBehaviour:
|
|||
DenseViewWidthThreshold: 512
|
||||
_disableAutoReloadInBackground: 0
|
||||
ImportedScriptPaths:
|
||||
- Assets/Scripts/InputSystem/PlayerInput.cs
|
||||
- Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs
|
||||
- Assets/Scripts/SourceGenerators/MinigameLoaderGenerator.cs
|
||||
- Assets/Scripts/GlobalGameManager.cs
|
||||
- Assets/Scripts/InputSystem/InputController.cs
|
||||
- Assets/Scripts/Minigames.cs
|
||||
- Assets/Editor/CreateAssetBundles.cs
|
||||
- Assets/Editor/CreateMinigameScriptTemplate.cs
|
||||
PathsToSkipImportEvent: []
|
||||
PathsToIgnoreOverwriteSettingOnAttribute: []
|
||||
|
|
Loading…
Reference in a new issue