Skip to content

Commit

Permalink
🔩 0.7.0 Release > Merge pull request #17 from CarterGames/release
Browse files Browse the repository at this point in the history
🚧 0.7.x update
  • Loading branch information
JonathanMCarter authored Jul 14, 2024
2 parents 564167c + b801821 commit d06f8ab
Show file tree
Hide file tree
Showing 131 changed files with 2,714 additions and 642 deletions.
3 changes: 3 additions & 0 deletions Carter Games/The Cart/Code/Editor/Core/Attributes.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
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2024 Carter Games
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

using CarterGames.Cart.Core;
using UnityEditor;
using UnityEngine;

namespace CarterGames.TheCart.Core.Editor
{
[CustomPropertyDrawer(typeof(ReadonlyAttribute), true)]
public class ReadonlyPropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);

EditorGUI.BeginDisabledGroup(true);
EditorGUI.PropertyField(position, property, label);
EditorGUI.EndDisabledGroup();

EditorGUI.EndProperty();
}
}
}

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

3 changes: 3 additions & 0 deletions Carter Games/The Cart/Code/Editor/Core/Data.meta

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

3 changes: 3 additions & 0 deletions Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool.meta

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
@@ -0,0 +1,134 @@
/*
* Copyright (c) 2024 Carter Games
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

using System.IO;
using CarterGames.Cart.Core.Management.Editor;
using UnityEditor;
using UnityEngine;

namespace CarterGames.Cart.Core.Data.Editor
{
/// <summary>
/// Creates data asset for the user.
/// </summary>
public sealed class DataAssetCreator : EditorWindow
{
/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Fields
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */

private string dataAssetName;
private bool makeDataAssetWhenGenerated;

/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Menu Items
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */

/// <summary>
/// Makes a menu item for the creator to open.
/// </summary>
[MenuItem("Tools/Carter Games/The Cart/Core/Data/Asset Creator", priority = 515)]
private static void ShowWindow()
{
var window = GetWindow<DataAssetCreator>();
window.titleContent = new GUIContent("Data Asset Creator");
window.Show();
}

/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Methods
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */

/// <summary>
/// Draws the GUI.
/// </summary>
private void OnGUI()
{
GUILayout.Space(4f);

EditorGUILayout.BeginVertical("HelpBox");
GUILayout.Space(1.5f);

EditorGUILayout.LabelField("Data Asset Name", EditorStyles.boldLabel);
GeneralUtilEditor.DrawHorizontalGUILine();
dataAssetName = EditorGUILayout.TextField(dataAssetName);

GUILayout.Space(1.5f);
EditorGUILayout.EndVertical();

GUILayout.Space(4f);

EditorGUILayout.BeginVertical("HelpBox");
GUILayout.Space(1.5f);

EditorGUILayout.LabelField("Will create:", EditorStyles.boldLabel);
GeneralUtilEditor.DrawHorizontalGUILine();
EditorGUILayout.LabelField(new GUIContent("DataAsset: "),
new GUIContent("DataAsset" + dataAssetName + ".cs"));

GUILayout.Space(1.5f);
EditorGUILayout.EndVertical();

GUILayout.Space(4f);

if (GUILayout.Button("Create"))
{
CreateAssetFile(out string path);

AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

EditorUtility.RequestScriptReload();

if (Dialogue.Display("Data Asset Creator",
"Would you like to open the newly created files for editing?", "Yes", "No"))
{
AssetDatabase.OpenAsset(AssetDatabase.LoadAssetAtPath<TextAsset>(path));
}
}
}


/// <summary>
/// Creates the asset file for the data class the user is making.
/// </summary>
/// <param name="filePath">The path to create at.</param>
private void CreateAssetFile(out string filePath)
{
filePath = EditorUtility.SaveFilePanelInProject("Save New Data Asset Class",
$"DataAsset{dataAssetName}", "cs", "");

var script = AssetDatabase.FindAssets($"t:Script {nameof(DataAssetCreator)}")[0];
var pathToTextFile = AssetDatabase.GUIDToAssetPath(script);
pathToTextFile = pathToTextFile.Replace("DataAssetCreator.cs", "DataAssetTemplate.txt");

TextAsset template = AssetDatabase.LoadAssetAtPath<TextAsset>(pathToTextFile);
template = new TextAsset(template.text);
var replace = template.text.Replace("%DataAssetName%", "DataAsset" + dataAssetName);
replace = replace.Replace("%DataTypeName%", "Data" + dataAssetName);

File.WriteAllText(filePath, replace);
EditorUtility.SetDirty(AssetDatabase.LoadAssetAtPath<TextAsset>(pathToTextFile));
}
}
}

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
@@ -0,0 +1,12 @@
using CarterGames.Cart.Core.Data;
using UnityEngine;


namespace Data
{
[CreateAssetMenu(fileName = "%DataAssetName%")]
public class %DataAssetName% : DataAsset
{

}
}

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.

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
Expand Up @@ -14,24 +14,22 @@
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

using System.Collections.Generic;
using CarterGames.Cart.Core.Management.Editor;
using UnityEditor;
using UnityEngine;

namespace CarterGames.Cart.Core.Management.Editor
namespace CarterGames.Cart.Core.Data.Editor
{
/// <summary>
/// Handles the custom inspector for the Audio Manager asset index.
/// </summary>
[CustomEditor(typeof(CartSoAssetIndex))]
public sealed class CartSoLibraryAssetIndexEditor : UnityEditor.Editor
[CustomEditor(typeof(DataAssetIndex))]
public class DataAssetIndexEditor : UnityEditor.Editor
{
/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Fields
Expand Down Expand Up @@ -63,7 +61,7 @@ public override void OnInspectorGUI()

EditorGUILayout.BeginVertical("HelpBox");
GUILayout.Space(1.5f);
GeneralUtilEditor.DrawSoScriptSection((CartSoAssetIndex) target);
GeneralUtilEditor.DrawSoScriptSection((DataAssetIndex) target);
GUILayout.Space(1.5f);
EditorGUILayout.EndVertical();

Expand All @@ -77,7 +75,7 @@ public override void OnInspectorGUI()

if (GUILayout.Button("Refresh Index"))
{
AssetIndexHandler.UpdateIndex();
DataAssetIndexHandler.UpdateIndex();
}

GUILayout.Space(1.5f);
Expand Down Expand Up @@ -107,11 +105,15 @@ private void DrawAllReferencesSection()
GeneralUtilEditor.DrawHorizontalGUILine();

EditorGUI.indentLevel++;

EditorGUILayout.BeginHorizontal();

EditorGUI.BeginDisabledGroup(Application.isPlaying);
EditorGUILayout.PropertyField(serializedObject.Fp("assets"));
EditorGUILayout.PropertyField(serializedObject.Fp("assets").Fpr("list"));
EditorGUI.EndDisabledGroup();

EditorGUILayout.EndHorizontal();

EditorGUI.indentLevel--;

GUILayout.Space(1.5f);
Expand Down

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

Loading

0 comments on commit d06f8ab

Please sign in to comment.