Skip to content

Commit

Permalink
Added Editor Plus
Browse files Browse the repository at this point in the history
  • Loading branch information
Clément Couture committed Oct 21, 2021
1 parent 375333a commit 0d4f0af
Show file tree
Hide file tree
Showing 128 changed files with 5,114 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Assets/EditorPlus/Demo.meta

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

57 changes: 57 additions & 0 deletions Assets/EditorPlus/Demo/DemoScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Linq;
using EditorPlus;
using UnityEditor;
using UnityEngine;


public class DemoScript : MonoBehaviour {

[HelpBox("Try setting this to \"42\"")]
public string TextToSet;

[ShowIf(nameof(TextToSet), "42")]
public InnerClass IAmHidden;

public int[] IntValues;

#if UNITY_EDITOR
[OnEditorGUI]
private void SumInEditor() {
int sum = IntValues?.Sum() ?? 0;
EditorGUILayout.LabelField($"The sum of all the elements in the {nameof(IntValues)} list is {sum}");
}
#endif

[Button]
public void SetText() {
GetComponent<TextMesh>().text = TextToSet;
}

[Serializable]
public class InnerClass {

[Disabled]
public int NoOneCanEditThis = 2;

[CustomSpace(20, 20)]
[MinMaxSlider(-42, 42)]
public MinMaxInt INeedSomeSpace;

[HideInPlayMode]
public string LookAtMe;

[HideInEditMode]
public string SURPRISE = "SURPRISE";

[DisableInEditMode]
public string AndTryPressingPlay;

[Button("Display List Of Subclasses Of Component")]
private void DisplayListOfSubclassesOfComponent() {
Type targetType = typeof(Component);
Debug.Log($"All the sub-classes of {nameof(targetType)} are " +
$"{string.Join(", ", TypeUtils.GetAllTypesInheritingFrom(targetType).Select(t => t.Name))}");
}
}
}
11 changes: 11 additions & 0 deletions Assets/EditorPlus/Demo/DemoScript.cs.meta

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

Loading

0 comments on commit 0d4f0af

Please sign in to comment.