Skip to content

Commit d06519c

Browse files
committed
HUGE breakthrough, see commit description
- 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...
1 parent fc95d8a commit d06519c

23 files changed

+211
-160
lines changed

Libraries/CustomEditorExtensions/GuiStylesBank.cs renamed to Editor/GuiStylesBank.cs

File renamed without changes.

Libraries/CustomEditorExtensions/GuiStylesBank.cs.meta renamed to Editor/GuiStylesBank.cs.meta

File renamed without changes.

Editor/ItemAnimatorEditor.cs

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,78 @@
1-
using SebEssentials;
21
using UnityEditor;
32
using UnityEditor.AnimatedValues;
43
using UnityEngine;
54

6-
[CustomEditor(typeof(ItemAnimator))]
7-
public class ItemAnimatorEditor : Editor
8-
{
9-
public AnimBool isFloatingToggle;
10-
public AnimBool isRotatingToggle;
11-
private ItemAnimator.RotationDirection rot;
12-
13-
private void OnEnable()
14-
{
15-
isFloatingToggle = new AnimBool();
16-
isRotatingToggle = new AnimBool();
17-
}
185

19-
public override void OnInspectorGUI()
6+
namespace SebEssentials
7+
{
8+
[CustomEditor(typeof(ItemAnimator))]
9+
public class ItemAnimatorEditor : Editor
2010
{
21-
ItemAnimator t = target as ItemAnimator;
22-
23-
isFloatingToggle.target = EditorGUILayout.ToggleLeft(
24-
new GUIContent("Floating",
25-
"Set to true if you want your object to bob up and down, and to make the parameters available."),
26-
isFloatingToggle.target, GuiStylesBank.boldStyle);
11+
public AnimBool isFloatingToggle;
12+
public AnimBool isRotatingToggle;
13+
private ItemAnimator.RotationDirection rot;
2714

28-
if (EditorGUILayout.BeginFadeGroup(isFloatingToggle.faded))
15+
private void OnEnable()
2916
{
30-
EditorGUILayout.BeginVertical();
31-
t.isFloating = true;
32-
t.intensity =
33-
EditorGUILayout.Slider(
34-
new GUIContent("Amplitude",
35-
"Amplitude of the vertical movement. The higher the value, the higher the range. The middle will always be the starting position."),
36-
t.intensity, 0, 30);
37-
t.speed = EditorGUILayout.Slider(
38-
new GUIContent("Speed",
39-
"The speed of the variation. The higher the value, the shorter the time will be to execute a complete cycle."),
40-
t.speed, 0, 30);
41-
EditorGUILayout.EndVertical();
17+
isFloatingToggle = new AnimBool();
18+
isRotatingToggle = new AnimBool();
4219
}
43-
else
20+
21+
public override void OnInspectorGUI()
4422
{
45-
t.isFloating = false;
46-
}
23+
ItemAnimator t = target as ItemAnimator;
4724

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

50-
isRotatingToggle.target =
51-
EditorGUILayout.ToggleLeft(
52-
new GUIContent("Rotating",
53-
"Set it to true if you want your object to rotate, and have the rest of the parameters available."),
54-
isRotatingToggle.target, GuiStylesBank.boldStyle);
55-
if (EditorGUILayout.BeginFadeGroup(isRotatingToggle.faded))
56-
{
57-
t.isRotating = true;
58-
t.rotationDirection =
59-
(ItemAnimator.RotationDirection) EditorGUILayout.EnumPopup(
60-
new GUIContent("Rotation direction",
61-
"Technically, you could just put a negative value to rotate in the opposite direction, but I wanted to have a fancy inspector."),
62-
t.rotationDirection);
63-
t.rotateSpeed =
64-
EditorGUILayout.Slider(new GUIContent("Rotating speed", "I think that you get what this one is for :)"),
65-
t.rotateSpeed, .1f, 30f);
66-
}
67-
else
68-
{
69-
t.isRotating = false;
70-
}
30+
if (EditorGUILayout.BeginFadeGroup(isFloatingToggle.faded))
31+
{
32+
EditorGUILayout.BeginVertical();
33+
t.isFloating = true;
34+
t.intensity =
35+
EditorGUILayout.Slider(
36+
new GUIContent("Amplitude",
37+
"Amplitude of the vertical movement. The higher the value, the higher the range. The middle will always be the starting position."),
38+
t.intensity, 0, 30);
39+
t.speed = EditorGUILayout.Slider(
40+
new GUIContent("Speed",
41+
"The speed of the variation. The higher the value, the shorter the time will be to execute a complete cycle."),
42+
t.speed, 0, 30);
43+
EditorGUILayout.EndVertical();
44+
}
45+
else
46+
{
47+
t.isFloating = false;
48+
}
7149

72-
EditorGUILayout.EndFadeGroup();
50+
EditorGUILayout.EndFadeGroup();
51+
52+
isRotatingToggle.target =
53+
EditorGUILayout.ToggleLeft(
54+
new GUIContent("Rotating",
55+
"Set it to true if you want your object to rotate, and have the rest of the parameters available."),
56+
isRotatingToggle.target, GuiStylesBank.boldStyle);
57+
if (EditorGUILayout.BeginFadeGroup(isRotatingToggle.faded))
58+
{
59+
t.isRotating = true;
60+
t.rotationDirection =
61+
(ItemAnimator.RotationDirection) EditorGUILayout.EnumPopup(
62+
new GUIContent("Rotation direction",
63+
"Technically, you could just put a negative value to rotate in the opposite direction, but I wanted to have a fancy inspector."),
64+
t.rotationDirection);
65+
t.rotateSpeed =
66+
EditorGUILayout.Slider(
67+
new GUIContent("Rotating speed", "I think that you get what this one is for :)"),
68+
t.rotateSpeed, .1f, 30f);
69+
}
70+
else
71+
{
72+
t.isRotating = false;
73+
}
74+
75+
EditorGUILayout.EndFadeGroup();
76+
}
7377
}
7478
}

Editor/SebEssentials.EditorScripts.asmdef

Lines changed: 0 additions & 20 deletions
This file was deleted.

Editor/TodosAndNotes.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
[CreateAssetMenu(fileName = "New Todo list", menuName = "Todo list")]
6+
public class TodosAndNotes : ScriptableObject
7+
{
8+
public string title;
9+
public string content;
10+
public List<String> todos;
11+
12+
public void Init(string title, string content, List<string> todos)
13+
{
14+
this.title = title;
15+
this.content = content;
16+
this.todos = todos;
17+
}
18+
19+
}

Editor/TodosAndNotes.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using UnityEditor;
5+
using UnityEngine;
6+
using SebEssentials;
7+
8+
public class TodosAndNotesEditorWindow : EditorWindow
9+
{
10+
public string noteTitle;
11+
public string notes;
12+
private string[] todos;
13+
private int todoCap;
14+
private string path = "Assets/nameless.asset";
15+
16+
17+
private void Awake()
18+
{
19+
todos = new string[todoCap];
20+
}
21+
22+
private void OnGUI()
23+
{
24+
GUILayout.Label("Todos and notes", EditorStyles.whiteLargeLabel);
25+
26+
FirstBlock();
27+
28+
List();
29+
30+
31+
Export();
32+
}
33+
34+
private void List()
35+
{
36+
GUILayout.BeginHorizontal();
37+
38+
if (GUILayout.Button(new GUIContent("-", "Remove a line"), EditorStyles.miniButton, GUILayout.Width(30),
39+
GUILayout.Height(30)))
40+
{
41+
todoCap--;
42+
Array.Resize(ref todos, todoCap);
43+
}
44+
45+
EditorGUILayout.LabelField(todoCap.ToString(), EditorStyles.whiteLargeLabel, GUILayout.MaxWidth(40));
46+
47+
if (GUILayout.Button(new GUIContent("+", "Add a line"), EditorStyles.miniButton, GUILayout.Width(30),
48+
GUILayout.Height(30)))
49+
{
50+
todoCap++;
51+
Array.Resize(ref todos, todoCap);
52+
}
53+
54+
GUILayout.EndHorizontal();
55+
56+
for (int i = 0; i < todoCap; i++)
57+
{
58+
EditorGUILayout.BeginHorizontal();
59+
todos[i] = EditorGUILayout.TextField(todos[i]);
60+
if (GUILayout.Button("X"))
61+
{
62+
var temp = todos.ToList();
63+
temp.RemoveAt(i);
64+
todos = new List<string>(temp).ToArray();
65+
todoCap--;
66+
}
67+
68+
EditorGUILayout.EndHorizontal();
69+
}
70+
}
71+
72+
private void Export()
73+
{
74+
GUILayout.BeginHorizontal();
75+
EditorGUILayout.PrefixLabel("Path : ");
76+
path = EditorGUILayout.TextField(path);
77+
78+
if (GUILayout.Button("Export as Scriptable Object"))
79+
{
80+
TodosAndNotes asset = CreateInstance<TodosAndNotes>();
81+
asset.title = noteTitle;
82+
asset.content = notes;
83+
asset.todos = todos.ToList();
84+
var temp = path;
85+
path = AssetDatabase.GenerateUniqueAssetPath($"{path}/{noteTitle}.asset");
86+
AssetDatabase.CreateAsset(asset, path);
87+
AssetDatabase.SaveAssets();
88+
EditorUtility.FocusProjectWindow();
89+
Selection.activeObject = asset;
90+
path = String.Empty;
91+
}
92+
93+
GUILayout.EndHorizontal();
94+
}
95+
96+
private void FirstBlock()
97+
{
98+
EditorGUILayout.BeginVertical();
99+
EditorGUILayout.LabelField("Title");
100+
noteTitle = EditorGUILayout.TextField(noteTitle);
101+
EditorGUILayout.EndVertical();
102+
EditorGUILayout.BeginVertical();
103+
EditorGUILayout.LabelField("Content");
104+
notes = EditorGUILayout.TextArea(notes, GUILayout.Height(50));
105+
EditorGUILayout.EndVertical();
106+
}
107+
108+
109+
[MenuItem("Tools/SebEssentials/Todos")]
110+
public static void ShowWindow()
111+
{
112+
GetWindow<TodosAndNotesEditorWindow>("Todos and notes");
113+
}
114+
}

Editor/TodosAndNotesEditorWindow.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"name": "SebEssentials.Libraries",
2+
"name": "com.SebEssentials.Editor",
33
"rootNamespace": "",
44
"references": [
5-
"GUID:0acc523941302664db1f4e527237feb3",
6-
"GUID:27619889b8ba8c24980f49ee34dbb44a"
5+
"GUID:5514f3497a1880f419f2e48043e46bf6"
76
],
87
"includePlatforms": [
98
"Editor"

Libraries/SebEssentials.Libraries.asmdef.meta renamed to Editor/com.SebEssentials.Editor.asmdef.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)