Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuhiko-unity committed Jul 1, 2014
0 parents commit 0391e09
Show file tree
Hide file tree
Showing 38 changed files with 1,629 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Assets/SceneObjectReference.meta

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

5 changes: 5 additions & 0 deletions Assets/SceneObjectReference/Editor.meta

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

153 changes: 153 additions & 0 deletions Assets/SceneObjectReference/Editor/ReferenceAllObjectWindow.cs
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.

14 changes: 14 additions & 0 deletions Assets/SceneObjectReference/Editor/ReferenceObject.cs
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;
}
}
8 changes: 8 additions & 0 deletions Assets/SceneObjectReference/Editor/ReferenceObject.cs.meta

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

60 changes: 60 additions & 0 deletions Assets/SceneObjectReference/Editor/ReferenceObjectWindow.cs
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.

60 changes: 60 additions & 0 deletions Assets/SceneObjectReference/Editor/ReferencedObjectWindow.cs
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.

Loading

0 comments on commit 0391e09

Please sign in to comment.