public SerializedComponent(SerializedComponent c) { m_instanceData = c.m_instanceData; m_attachedComponents = new List <ComponentInfo> (); for (int i = 0; i < c.m_attachedComponents.Count; ++i) { m_attachedComponents.Add(new ComponentInfo(c.m_attachedComponents [i])); } }
public void OnInspectorGUI(SerializedComponent parent) { DrawHeader(parent); // indent inspector GUILayout.BeginHorizontal(); GUILayout.Space(16f); GUILayout.BeginVertical(); DrawDefaultInspector(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
public override bool Equals(object rhs) { SerializedComponent other = rhs as SerializedComponent; if (other == null) { return(false); } else { return(other == this); } }
public void DrawHeader(SerializedComponent parent) { if (s_popupIcon == null) { s_popupIcon = EditorGUIUtility.Load("icons/_Popup.png") as Texture2D; } if (s_helpIcon == null) { s_helpIcon = EditorGUIUtility.Load("icons/_Help.png") as Texture2D; } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); using (new EditorGUILayout.HorizontalScope()) { var thumbnail = AssetPreview.GetMiniTypeThumbnail(m_componentType); if (thumbnail == null) { if (typeof(MonoBehaviour).IsAssignableFrom(m_componentType)) { thumbnail = AssetPreview.GetMiniTypeThumbnail(typeof(MonoScript)); } else { thumbnail = AssetPreview.GetMiniTypeThumbnail(typeof(UnityEngine.Object)); } } GUILayout.Label(thumbnail, GUILayout.Width(32f), GUILayout.Height(32f)); if (m_component is Behaviour) { Behaviour b = m_component as Behaviour; b.enabled = EditorGUILayout.ToggleLeft(m_componentType.Name, b.enabled, EditorStyles.boldLabel); } else { GUILayout.Label(m_componentType.Name, EditorStyles.boldLabel); } GUILayout.FlexibleSpace(); if (Help.HasHelpForObject(m_component)) { var tooltip = $"Open Reference for {m_componentType.Name}."; if (GUILayout.Button(new GUIContent(s_helpIcon, tooltip), EditorStyles.miniLabel, GUILayout.Width(20f), GUILayout.Height(20f))) { Help.ShowHelpForObject(m_component); } } if (GUILayout.Button(s_popupIcon, EditorStyles.miniLabel, GUILayout.Width(20f), GUILayout.Height(20f))) { GenericMenu m = new GenericMenu(); m.AddItem(new GUIContent("Copy Component"), false, () => { UnityEditorInternal.ComponentUtility.CopyComponent(m_component); }); var pasteLabel = new GUIContent("Paste Component Values"); m.AddItem(pasteLabel, false, () => { UnityEditorInternal.ComponentUtility.PasteComponentValues(m_component); }); m.AddItem(new GUIContent("Remove Component"), false, () => { parent.RemoveComponent(this); }); MonoScript s = TypeUtility.LoadMonoScript(m_componentType.AssemblyQualifiedName); if (s != null) { m.AddSeparator(""); m.AddItem( new GUIContent("Edit Script"), false, () => { AssetDatabase.OpenAsset(s, 0); } ); } m.ShowAsContext(); } } GUILayout.Space(4f); }