Skip to content

Commit

Permalink
HUGE breakthrough, see commit description
Browse files Browse the repository at this point in the history
- Finally understood what the deal is with Assembly Definitions
- Package BUILDS FINALLY
- Rough WORKING version of SebTodosLists
- Namespaces needs to be redefined
- Finally understood the main difference between Runtime and Editor folders, put script in correct ones
- etc...
  • Loading branch information
Glaas committed Apr 20, 2021
1 parent fc95d8a commit d06519c
Show file tree
Hide file tree
Showing 23 changed files with 211 additions and 160 deletions.
File renamed without changes.
File renamed without changes.
122 changes: 63 additions & 59 deletions Editor/ItemAnimatorEditor.cs
Original file line number Diff line number Diff line change
@@ -1,74 +1,78 @@
using SebEssentials;
using UnityEditor;
using UnityEditor.AnimatedValues;
using UnityEngine;

[CustomEditor(typeof(ItemAnimator))]
public class ItemAnimatorEditor : Editor
{
public AnimBool isFloatingToggle;
public AnimBool isRotatingToggle;
private ItemAnimator.RotationDirection rot;

private void OnEnable()
{
isFloatingToggle = new AnimBool();
isRotatingToggle = new AnimBool();
}

public override void OnInspectorGUI()
namespace SebEssentials
{
[CustomEditor(typeof(ItemAnimator))]
public class ItemAnimatorEditor : Editor
{
ItemAnimator t = target as ItemAnimator;

isFloatingToggle.target = EditorGUILayout.ToggleLeft(
new GUIContent("Floating",
"Set to true if you want your object to bob up and down, and to make the parameters available."),
isFloatingToggle.target, GuiStylesBank.boldStyle);
public AnimBool isFloatingToggle;
public AnimBool isRotatingToggle;
private ItemAnimator.RotationDirection rot;

if (EditorGUILayout.BeginFadeGroup(isFloatingToggle.faded))
private void OnEnable()
{
EditorGUILayout.BeginVertical();
t.isFloating = true;
t.intensity =
EditorGUILayout.Slider(
new GUIContent("Amplitude",
"Amplitude of the vertical movement. The higher the value, the higher the range. The middle will always be the starting position."),
t.intensity, 0, 30);
t.speed = EditorGUILayout.Slider(
new GUIContent("Speed",
"The speed of the variation. The higher the value, the shorter the time will be to execute a complete cycle."),
t.speed, 0, 30);
EditorGUILayout.EndVertical();
isFloatingToggle = new AnimBool();
isRotatingToggle = new AnimBool();
}
else

public override void OnInspectorGUI()
{
t.isFloating = false;
}
ItemAnimator t = target as ItemAnimator;

EditorGUILayout.EndFadeGroup();
isFloatingToggle.target = EditorGUILayout.ToggleLeft(
new GUIContent("Floating",
"Set to true if you want your object to bob up and down, and to make the parameters available."),
isFloatingToggle.target, GuiStylesBank.boldStyle);

isRotatingToggle.target =
EditorGUILayout.ToggleLeft(
new GUIContent("Rotating",
"Set it to true if you want your object to rotate, and have the rest of the parameters available."),
isRotatingToggle.target, GuiStylesBank.boldStyle);
if (EditorGUILayout.BeginFadeGroup(isRotatingToggle.faded))
{
t.isRotating = true;
t.rotationDirection =
(ItemAnimator.RotationDirection) EditorGUILayout.EnumPopup(
new GUIContent("Rotation direction",
"Technically, you could just put a negative value to rotate in the opposite direction, but I wanted to have a fancy inspector."),
t.rotationDirection);
t.rotateSpeed =
EditorGUILayout.Slider(new GUIContent("Rotating speed", "I think that you get what this one is for :)"),
t.rotateSpeed, .1f, 30f);
}
else
{
t.isRotating = false;
}
if (EditorGUILayout.BeginFadeGroup(isFloatingToggle.faded))
{
EditorGUILayout.BeginVertical();
t.isFloating = true;
t.intensity =
EditorGUILayout.Slider(
new GUIContent("Amplitude",
"Amplitude of the vertical movement. The higher the value, the higher the range. The middle will always be the starting position."),
t.intensity, 0, 30);
t.speed = EditorGUILayout.Slider(
new GUIContent("Speed",
"The speed of the variation. The higher the value, the shorter the time will be to execute a complete cycle."),
t.speed, 0, 30);
EditorGUILayout.EndVertical();
}
else
{
t.isFloating = false;
}

EditorGUILayout.EndFadeGroup();
EditorGUILayout.EndFadeGroup();

isRotatingToggle.target =
EditorGUILayout.ToggleLeft(
new GUIContent("Rotating",
"Set it to true if you want your object to rotate, and have the rest of the parameters available."),
isRotatingToggle.target, GuiStylesBank.boldStyle);
if (EditorGUILayout.BeginFadeGroup(isRotatingToggle.faded))
{
t.isRotating = true;
t.rotationDirection =
(ItemAnimator.RotationDirection) EditorGUILayout.EnumPopup(
new GUIContent("Rotation direction",
"Technically, you could just put a negative value to rotate in the opposite direction, but I wanted to have a fancy inspector."),
t.rotationDirection);
t.rotateSpeed =
EditorGUILayout.Slider(
new GUIContent("Rotating speed", "I think that you get what this one is for :)"),
t.rotateSpeed, .1f, 30f);
}
else
{
t.isRotating = false;
}

EditorGUILayout.EndFadeGroup();
}
}
}
20 changes: 0 additions & 20 deletions Editor/SebEssentials.EditorScripts.asmdef

This file was deleted.

19 changes: 19 additions & 0 deletions Editor/TodosAndNotes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "New Todo list", menuName = "Todo list")]
public class TodosAndNotes : ScriptableObject
{
public string title;
public string content;
public List<String> todos;

public void Init(string title, string content, List<string> todos)
{
this.title = title;
this.content = content;
this.todos = todos;
}

}
3 changes: 3 additions & 0 deletions Editor/TodosAndNotes.cs.meta

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

114 changes: 114 additions & 0 deletions Editor/TodosAndNotesEditorWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using SebEssentials;

public class TodosAndNotesEditorWindow : EditorWindow
{
public string noteTitle;
public string notes;
private string[] todos;
private int todoCap;
private string path = "Assets/nameless.asset";


private void Awake()
{
todos = new string[todoCap];
}

private void OnGUI()
{
GUILayout.Label("Todos and notes", EditorStyles.whiteLargeLabel);

FirstBlock();

List();


Export();
}

private void List()
{
GUILayout.BeginHorizontal();

if (GUILayout.Button(new GUIContent("-", "Remove a line"), EditorStyles.miniButton, GUILayout.Width(30),
GUILayout.Height(30)))
{
todoCap--;
Array.Resize(ref todos, todoCap);
}

EditorGUILayout.LabelField(todoCap.ToString(), EditorStyles.whiteLargeLabel, GUILayout.MaxWidth(40));

if (GUILayout.Button(new GUIContent("+", "Add a line"), EditorStyles.miniButton, GUILayout.Width(30),
GUILayout.Height(30)))
{
todoCap++;
Array.Resize(ref todos, todoCap);
}

GUILayout.EndHorizontal();

for (int i = 0; i < todoCap; i++)
{
EditorGUILayout.BeginHorizontal();
todos[i] = EditorGUILayout.TextField(todos[i]);
if (GUILayout.Button("X"))
{
var temp = todos.ToList();
temp.RemoveAt(i);
todos = new List<string>(temp).ToArray();
todoCap--;
}

EditorGUILayout.EndHorizontal();
}
}

private void Export()
{
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Path : ");
path = EditorGUILayout.TextField(path);

if (GUILayout.Button("Export as Scriptable Object"))
{
TodosAndNotes asset = CreateInstance<TodosAndNotes>();
asset.title = noteTitle;
asset.content = notes;
asset.todos = todos.ToList();
var temp = path;
path = AssetDatabase.GenerateUniqueAssetPath($"{path}/{noteTitle}.asset");
AssetDatabase.CreateAsset(asset, path);
AssetDatabase.SaveAssets();
EditorUtility.FocusProjectWindow();
Selection.activeObject = asset;
path = String.Empty;
}

GUILayout.EndHorizontal();
}

private void FirstBlock()
{
EditorGUILayout.BeginVertical();
EditorGUILayout.LabelField("Title");
noteTitle = EditorGUILayout.TextField(noteTitle);
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical();
EditorGUILayout.LabelField("Content");
notes = EditorGUILayout.TextArea(notes, GUILayout.Height(50));
EditorGUILayout.EndVertical();
}


[MenuItem("Tools/SebEssentials/Todos")]
public static void ShowWindow()
{
GetWindow<TodosAndNotesEditorWindow>("Todos and notes");
}
}
3 changes: 3 additions & 0 deletions Editor/TodosAndNotesEditorWindow.cs.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
@@ -1,9 +1,8 @@
{
"name": "SebEssentials.Libraries",
"name": "com.SebEssentials.Editor",
"rootNamespace": "",
"references": [
"GUID:0acc523941302664db1f4e527237feb3",
"GUID:27619889b8ba8c24980f49ee34dbb44a"
"GUID:5514f3497a1880f419f2e48043e46bf6"
],
"includePlatforms": [
"Editor"
Expand Down

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

8 changes: 0 additions & 8 deletions Libraries.meta

This file was deleted.

8 changes: 0 additions & 8 deletions Libraries/CustomEditorExtensions.meta

This file was deleted.

8 changes: 0 additions & 8 deletions Libraries/MathsExtensions.meta

This file was deleted.

File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions Runtime/Misc/ItemAnimator/ItemAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public enum RotationDirection
}

//Public, to show in inspector

public bool isFloating, isRotating;
public float intensity = 1, speed = 1;
public float rotateSpeed = 2;
Expand Down
19 changes: 0 additions & 19 deletions Runtime/Misc/SebEssentials.Misc.asmdef

This file was deleted.

7 changes: 0 additions & 7 deletions Runtime/Misc/SebEssentials.Misc.asmdef.meta

This file was deleted.

Loading

0 comments on commit d06519c

Please sign in to comment.