Tanoda
pb_MetaDataEditor.cs
Go to the documentation of this file.
1using UnityEngine;
2using UnityEditor;
3using System.Collections;
4using System.Collections.Generic;
5using GILES;
7
8namespace GILES.UnityEditor
9{
13 [CustomEditor(typeof(pb_MetaDataComponent))]
14 public class pb_MetaDataEditor : Editor
15 {
16 // Store reference to the component target.
18
19 // The component diff as stored by pb_MetaData.
21
22 // Remember which component diffs have been expanded.
23 Dictionary<Component, bool> dropdowns = new Dictionary<Component, bool>();
24
25 void OnEnable()
26 {
27 data = (pb_MetaDataComponent) target;
28 diff = data.metadata.componentDiff;
29 }
30
31 public override void OnInspectorGUI()
32 {
33 serializedObject.Update();
34
35 // Non-user-editable data.
36 GUILayout.Label("Asset Type: " + data.metadata.assetType);
37 GUILayout.Label("File ID: " + data.metadata.fileId);
38 GUILayout.Label("Asset Path: " + data.metadata.assetBundlePath);
39
40 // Show the stored component diffs.
41 GUILayout.Label("Modified Values", EditorStyles.boldLabel);
42
43 int labelWidth = (int) Mathf.Min(Screen.width/2, 100);
44
45 foreach(KeyValuePair<Component, Dictionary<string, object>> kvp in diff.modifiedValues)
46 {
47 if(!dropdowns.ContainsKey(kvp.Key))
48 dropdowns.Add(kvp.Key, false);
49
50 dropdowns[kvp.Key] = EditorGUILayout.Foldout(dropdowns[kvp.Key], kvp.Key.ToString());
51
52 if(dropdowns[kvp.Key])
53 {
54 foreach(KeyValuePair<string, object> changes in kvp.Value)
55 {
56 GUILayout.BeginHorizontal();
57
58 GUILayout.Label(changes.Key, GUILayout.MinWidth(labelWidth), GUILayout.MaxWidth(labelWidth));
59
60 GUILayout.Label(changes.Value.ToString().Truncate(128));
61
62 GUILayout.EndHorizontal();
63 }
64 }
65 }
66 }
67
68 }
69}
UnityEngine.Component Component
Dictionary< Component, Dictionary< string, object > > modifiedValues
pb_ComponentDiff componentDiff
Definition: pb_MetaData.cs:26
pb_AssetBundlePath assetBundlePath
Definition: pb_MetaData.cs:75
AssetType assetType
Definition: pb_MetaData.cs:83