-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
- Loading branch information
There are no files selected for viewing
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,153 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using UnityEditor; | ||
using System.Collections.Generic; | ||
using terasurware; | ||
|
||
public class ReferenceAllObjectWindow : EditorWindow | ||
{ | ||
|
||
[MenuItem("Window/Referenced/All")] | ||
static void Init () | ||
{ | ||
var window = GetWindow (typeof(ReferenceAllObjectWindow)); | ||
window.Show (); | ||
} | ||
|
||
List<ReferenceObject> refObjectList = new List<ReferenceObject> (); | ||
Vector2 current = new Vector2 (); | ||
|
||
void OnInspectorUpdate () | ||
{ | ||
Repaint (); | ||
} | ||
|
||
List<GameObject> allObject; | ||
bool isHiding = false; | ||
|
||
void ParentShow (Transform parent) | ||
{ | ||
if (parent != null) { | ||
parent.gameObject.hideFlags = HideFlags.None; | ||
ParentShow (parent.parent); | ||
} | ||
} | ||
|
||
void OnDestroy () | ||
{ | ||
ShowAllObject (); | ||
} | ||
|
||
void HideNoCommunication () | ||
{ | ||
isHiding = true; | ||
|
||
|
||
UpdateAllObject (); | ||
UpdateList (); | ||
foreach (var obj in allObject) { | ||
obj.hideFlags = HideFlags.HideInHierarchy; | ||
} | ||
|
||
foreach (var item in refObjectList) { | ||
ParentShow (item.rootObject.transform); | ||
ParentShow (item.thisObject.transform); | ||
} | ||
} | ||
|
||
void ShowAllObject () | ||
{ | ||
isHiding = false; | ||
|
||
UpdateAllObject (); | ||
|
||
foreach (var obj in allObject) { | ||
obj.hideFlags = HideFlags.None; | ||
} | ||
} | ||
|
||
void Update () | ||
{ | ||
|
||
if (EditorApplication.isPaused || !EditorApplication.isPlaying) { | ||
UpdateAllObject (); | ||
UpdateList (); | ||
} | ||
} | ||
|
||
void UpdateAllObject () | ||
{ | ||
allObject = SceneObjectUtility.GetAllObjectsInScene (false); | ||
} | ||
|
||
void UpdateList () | ||
{ | ||
refObjectList.Clear (); | ||
|
||
|
||
foreach (var obj in allObject) { | ||
SceneObjectUtility.GetReferenceObject (obj, refObjectList); | ||
} | ||
refObjectList.Sort ((x,y) => { | ||
return x.thisObject.GetInstanceID () - y.thisObject.GetInstanceID (); }); | ||
} | ||
|
||
void OnGUI () | ||
{ | ||
|
||
if (EditorApplication.isPlaying && !EditorApplication.isPaused) { | ||
if (GUILayout.Button ("pause")) { | ||
EditorApplication.isPaused = true; | ||
} | ||
return; | ||
} | ||
|
||
if (isHiding == false && GUILayout.Button ("hide")) { | ||
HideNoCommunication (); | ||
} | ||
|
||
if (isHiding == true && GUILayout.Button ("show")) { | ||
ShowAllObject (); | ||
} | ||
|
||
GUIStyle styles = new GUIStyle (); | ||
styles.margin.left = 10; | ||
styles.margin.top = 5; | ||
|
||
current = EditorGUILayout.BeginScrollView (current); | ||
|
||
int preGameObjectID = 0; | ||
|
||
foreach (var refObject in refObjectList) { | ||
try { | ||
|
||
if (preGameObjectID != refObject.thisObject.GetInstanceID ()) { | ||
preGameObjectID = refObject.thisObject.GetInstanceID (); | ||
EditorGUILayout.Space (); | ||
EditorGUILayout.ObjectField (refObject.thisObject, refObject.thisObject.GetType ()); | ||
} | ||
|
||
string msg = string.Format ("{2}.{1} -> ({0}){4}", | ||
refObject.value.GetType ().Name, | ||
refObject.fieldName, | ||
refObject.valueType.Name, | ||
refObject.thisObject.name, | ||
refObject.value.name); | ||
|
||
GUILayout.BeginHorizontal (); | ||
GUILayout.Label (EditorGUIUtility.ObjectContent (null, refObject.valueType).image, GUILayout.Height (16), GUILayout.Width (16)); | ||
if (GUILayout.Button (msg, styles)) { | ||
EditorGUIUtility.PingObject (refObject.value); | ||
|
||
Selection.activeGameObject = refObject.thisObject; | ||
} | ||
GUILayout.EndHorizontal (); | ||
} catch (MissingReferenceException) { | ||
} catch (MissingComponentException) { | ||
} catch (UnassignedReferenceException){ | ||
} | ||
} | ||
|
||
EditorGUILayout.EndScrollView (); | ||
} | ||
} |
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,14 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
namespace terasurware | ||
{ | ||
public class ReferenceObject { | ||
|
||
public GameObject thisObject; | ||
public GameObject rootObject; | ||
public Object value; | ||
public System.Type valueType; | ||
public string fieldName; | ||
} | ||
} |
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,60 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using UnityEditor; | ||
using System.Collections.Generic; | ||
using terasurware; | ||
|
||
|
||
public class ReferenceObjectWindow : EditorWindow { | ||
|
||
[MenuItem("Window/Referenced/to object")] | ||
static void Init () { | ||
var window = GetWindow( typeof(ReferenceObjectWindow)); | ||
window.Show(); | ||
} | ||
|
||
List<ReferenceObject> refObjectList = new List<ReferenceObject>(); | ||
|
||
void OnInspectorUpdate () { | ||
Repaint (); | ||
} | ||
|
||
Vector2 current; | ||
|
||
|
||
//void OnSelectionChange() | ||
void Update() | ||
{ | ||
refObjectList.Clear(); | ||
SceneObjectUtility.GetReferenceObject( Selection.activeGameObject, refObjectList) ; | ||
} | ||
|
||
void OnGUI () { | ||
GUIStyle styles = new GUIStyle(); | ||
styles.margin.left = 10; | ||
styles.margin.top = 5; | ||
|
||
current = EditorGUILayout.BeginScrollView(current); | ||
|
||
int preGameObjectID = 0; | ||
|
||
foreach( var refObject in refObjectList) | ||
{ | ||
if( preGameObjectID != refObject.rootObject.GetInstanceID()) | ||
{ | ||
preGameObjectID = refObject.rootObject.GetInstanceID(); | ||
EditorGUILayout.Space(); | ||
EditorGUILayout.ObjectField( refObject.value, refObject.valueType); | ||
} | ||
|
||
string msg = string.Format("{2}.{1} -> {0}", refObject.value.GetType().Name, refObject.fieldName, refObject.valueType.Name); | ||
|
||
GUILayout.BeginHorizontal(); | ||
GUILayout.Label(EditorGUIUtility.ObjectContent(null, typeof(ReferenceObject )).image, GUILayout.Height(16), GUILayout.Width(16)); | ||
GUILayout.Label(msg); | ||
GUILayout.EndHorizontal(); | ||
} | ||
|
||
EditorGUILayout.EndScrollView(); | ||
} | ||
} |
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,60 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using UnityEditor; | ||
using System.Collections.Generic; | ||
using terasurware; | ||
|
||
public class ReferencedObjectWindow : EditorWindow | ||
{ | ||
Vector2 current; | ||
|
||
List<ReferenceObject> refObjectList = new List<ReferenceObject>(); | ||
|
||
|
||
[MenuItem("Window/Referenced/for object")] | ||
static void Init () { | ||
var window = GetWindow( typeof(ReferencedObjectWindow)); | ||
window.Show(); | ||
} | ||
|
||
void OnInspectorUpdate () { | ||
Repaint (); | ||
} | ||
|
||
|
||
void OnSelectionChange() | ||
//void Update() | ||
{ | ||
refObjectList.Clear(); | ||
SceneObjectUtility.FindReferencedObject( Selection.activeGameObject, refObjectList) ; | ||
} | ||
|
||
void OnGUI () { | ||
GUIStyle styles = new GUIStyle(); | ||
styles.margin.left = 10; | ||
styles.margin.top = 5; | ||
|
||
current = EditorGUILayout.BeginScrollView(current); | ||
|
||
int preGameObjectID = 0; | ||
|
||
foreach( var refObject in refObjectList) | ||
{ | ||
if( preGameObjectID != refObject.rootObject.GetInstanceID()) | ||
{ | ||
preGameObjectID = refObject.rootObject.GetInstanceID(); | ||
EditorGUILayout.Space(); | ||
EditorGUILayout.ObjectField( refObject.value, refObject.valueType); | ||
} | ||
|
||
string msg = string.Format("{2} <- {0}.{1}", refObject.value.GetType().Name, refObject.fieldName, refObject.valueType.Name); | ||
|
||
GUILayout.BeginHorizontal(); | ||
GUILayout.Label(EditorGUIUtility.ObjectContent(null,refObject.valueType).image, GUILayout.Height(16), GUILayout.Width(16)); | ||
GUILayout.Label(msg); | ||
GUILayout.EndHorizontal(); | ||
} | ||
|
||
EditorGUILayout.EndScrollView(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.