Skip to content

Commit 13221c3

Browse files
committed
First stable version !
1 parent 79b3adf commit 13221c3

23 files changed

+1659
-0
lines changed

Assets/ReorderableListEx.cs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#if UNITY_EDITOR
2+
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
using UnityEngine;
6+
7+
using UnityEditor;
8+
using UnityEditorInternal;
9+
10+
namespace CPRUnitySystem
11+
{
12+
public class EasyReorderableList<T>
13+
{
14+
private ReorderableList reorderableList;
15+
private T t_default;
16+
private ElementCallback<T> elementDrawCallback;
17+
18+
public List<T> Data { get; private set; }
19+
public event OnListChangedEventHandler<T> OnListChanged;
20+
21+
public EasyReorderableList(string title, List<T> data, ElementCallback<T> drawCallback, T init = default(T))
22+
{
23+
Data = data;
24+
t_default = init;
25+
reorderableList = new ReorderableList(data, typeof(T));
26+
27+
reorderableList.drawHeaderCallback += (rect) =>
28+
{
29+
EditorGUI.LabelField(rect, title);
30+
};
31+
32+
reorderableList.drawElementCallback += (rect, index, isActive, isFocused) =>
33+
{
34+
Data[index] = elementDrawCallback(rect, Data[index], isActive, isFocused);
35+
};
36+
elementDrawCallback = drawCallback;
37+
38+
reorderableList.onAddCallback += OnAdd;
39+
reorderableList.onRemoveCallback += OnRemove;
40+
reorderableList.onChangedCallback += OnChangedCallback;
41+
}
42+
43+
public void DoList(Rect rect)
44+
{
45+
reorderableList.DoList(rect);
46+
}
47+
48+
public void DoLayoutList()
49+
{
50+
reorderableList.DoLayoutList();
51+
}
52+
53+
private void OnAdd(ReorderableList list)
54+
{
55+
Data.Add(t_default);
56+
}
57+
58+
private void OnRemove(ReorderableList list)
59+
{
60+
var remove = Data.Count;
61+
Data.RemoveAt(remove - 1);
62+
}
63+
64+
private void OnChangedCallback(ReorderableList list)
65+
{
66+
if (OnListChanged != null)
67+
OnListChanged(Data);
68+
}
69+
}
70+
71+
public delegate void OnListChangedEventHandler<T>(List<T> list);
72+
73+
public delegate T ElementCallback<T>(Rect rect, T data, bool isActive, bool isFocused);
74+
75+
[System.Obsolete("This interface is not used.")]
76+
public interface IReorderableSetting
77+
{
78+
79+
}
80+
}
81+
82+
#endif

Assets/ReorderableListEx.cs.meta

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Test Scriptable.asset

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_PrefabParentObject: {fileID: 0}
7+
m_PrefabInternal: {fileID: 0}
8+
m_GameObject: {fileID: 0}
9+
m_Enabled: 1
10+
m_EditorHideFlags: 0
11+
m_Script: {fileID: 11500000, guid: 92ca96b34f69341439dfc0764584ff13, type: 3}
12+
m_Name: New Test Scriptable
13+
m_EditorClassIdentifier:
14+
i: 05000000020000000300000000000000000000000000000000000000e8030000

Assets/Test Scriptable.asset.meta

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/TestScriptable.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEditor;
5+
using CPRUnitySystem;
6+
using System.Linq;
7+
8+
[CreateAssetMenu]
9+
public class TestScriptable : ScriptableObject
10+
{
11+
public List<int> i = new List<int>();
12+
13+
[CanEditMultipleObjects]
14+
[CustomEditor(typeof(TestScriptable))]
15+
public class TestEx : Editor
16+
{
17+
private EasyReorderableList<int> easyList;
18+
19+
public override void OnInspectorGUI()
20+
{
21+
var Target = target as TestScriptable;
22+
if(easyList == null) easyList = new EasyReorderableList<int>("i", Target.i, Draw, 10);
23+
easyList.DoLayoutList();
24+
EditorUtility.SetDirty(Target);
25+
}
26+
27+
public int Draw(Rect rect, int data, bool isActive, bool isFocused)
28+
{
29+
return EditorGUI.IntField(rect, "int", data);
30+
}
31+
}
32+
}

Assets/TestScriptable.cs.meta

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ProjectSettings/AudioManager.asset

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!11 &1
4+
AudioManager:
5+
m_ObjectHideFlags: 0
6+
m_Volume: 1
7+
Rolloff Scale: 1
8+
Doppler Factor: 1
9+
Default Speaker Mode: 2
10+
m_SampleRate: 0
11+
m_DSPBufferSize: 0
12+
m_VirtualVoiceCount: 512
13+
m_RealVoiceCount: 32
14+
m_SpatializerPlugin:
15+
m_AmbisonicDecoderPlugin:
16+
m_DisableAudio: 0
17+
m_VirtualizeEffects: 1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!236 &1
4+
ClusterInputManager:
5+
m_ObjectHideFlags: 0
6+
m_Inputs: []
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!55 &1
4+
PhysicsManager:
5+
m_ObjectHideFlags: 0
6+
serializedVersion: 7
7+
m_Gravity: {x: 0, y: -9.81, z: 0}
8+
m_DefaultMaterial: {fileID: 0}
9+
m_BounceThreshold: 2
10+
m_SleepThreshold: 0.005
11+
m_DefaultContactOffset: 0.01
12+
m_DefaultSolverIterations: 6
13+
m_DefaultSolverVelocityIterations: 1
14+
m_QueriesHitBackfaces: 0
15+
m_QueriesHitTriggers: 1
16+
m_EnableAdaptiveForce: 0
17+
m_ClothInterCollisionDistance: 0
18+
m_ClothInterCollisionStiffness: 0
19+
m_ContactsGeneration: 1
20+
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
21+
m_AutoSimulation: 1
22+
m_AutoSyncTransforms: 1
23+
m_ClothInterCollisionSettingsToggle: 0
24+
m_ContactPairsMode: 0
25+
m_BroadphaseType: 0
26+
m_WorldBounds:
27+
m_Center: {x: 0, y: 0, z: 0}
28+
m_Extent: {x: 250, y: 250, z: 250}
29+
m_WorldSubdivisions: 8
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!1045 &1
4+
EditorBuildSettings:
5+
m_ObjectHideFlags: 0
6+
serializedVersion: 2
7+
m_Scenes: []

0 commit comments

Comments
 (0)