minigame template

This commit is contained in:
minenice55 2024-01-18 23:39:20 -05:00
parent 49fcc959f4
commit e9bda6742e
9 changed files with 112 additions and 12 deletions

View file

@ -1,12 +1,10 @@
using System.IO; using System.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor; using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine; using UnityEngine;
using SatorImaging.UnitySourceGenerator.Editor;
using HeavenStudio;
public class CreateAssetBundles public class CreateAssetBundles
{ {
[MenuItem("Assets/Build AssetBundles/Current Platform")] [MenuItem("Assets/Build AssetBundles/Current Platform")]
@ -17,6 +15,8 @@ public class CreateAssetBundles
{ {
Directory.CreateDirectory(assetBundleDirectory); Directory.CreateDirectory(assetBundleDirectory);
} }
AssetDatabase.Refresh();
USGUtility.ForceGenerateByType(typeof(Minigames));
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget); BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
} }
@ -28,6 +28,8 @@ public class CreateAssetBundles
{ {
Directory.CreateDirectory(assetBundleDirectory); Directory.CreateDirectory(assetBundleDirectory);
} }
AssetDatabase.Refresh();
USGUtility.ForceGenerateByType(typeof(Minigames));
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneWindows); BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneWindows);
} }
@ -39,6 +41,8 @@ public class CreateAssetBundles
{ {
Directory.CreateDirectory(assetBundleDirectory); Directory.CreateDirectory(assetBundleDirectory);
} }
AssetDatabase.Refresh();
USGUtility.ForceGenerateByType(typeof(Minigames));
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneLinux64); BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneLinux64);
} }
@ -50,6 +54,8 @@ public class CreateAssetBundles
{ {
Directory.CreateDirectory(assetBundleDirectory); Directory.CreateDirectory(assetBundleDirectory);
} }
AssetDatabase.Refresh();
USGUtility.ForceGenerateByType(typeof(Minigames));
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneOSX); BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneOSX);
} }
} }

View 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));
}
}

View file

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

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 12ec433916efb3c4a895be2ac0dd6935
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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
{
}
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a701bb5358c08074b991f83428d52446
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -21,7 +21,7 @@ using System.IO;
namespace HeavenStudio namespace HeavenStudio
{ {
[UnitySourceGenerator(typeof(MinigameLoaderGenerator), OverwriteIfFileExists = false)] [UnitySourceGenerator(typeof(MinigameLoaderGenerator), OverwriteIfFileExists = true)]
public partial class Minigames public partial class Minigames
{ {
public enum RecommendedControlStyle public enum RecommendedControlStyle

View file

@ -110,7 +110,12 @@ namespace {context.TargetClass.Namespace}
"); ");
// USG: return true to tell USG to write content into OutputPath. false to do nothing. // USG: return true to tell USG to write content into OutputPath. false to do nothing.
// only write if changes are made.
if (!System.IO.File.Exists(context.OutputPath))
return true; return true;
string oldContent = System.IO.File.ReadAllText(context.OutputPath);
return sb.ToString() != oldContent;
} }
#pragma warning restore IDE0051 #pragma warning restore IDE0051

View file

@ -18,11 +18,8 @@ MonoBehaviour:
DenseViewWidthThreshold: 512 DenseViewWidthThreshold: 512
_disableAutoReloadInBackground: 0 _disableAutoReloadInBackground: 0
ImportedScriptPaths: 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/Scripts/Minigames.cs
- Assets/Editor/CreateAssetBundles.cs
- Assets/Editor/CreateMinigameScriptTemplate.cs
PathsToSkipImportEvent: [] PathsToSkipImportEvent: []
PathsToIgnoreOverwriteSettingOnAttribute: [] PathsToIgnoreOverwriteSettingOnAttribute: []