/// <summary> /// Creates a clone of the object. /// </summary> /// <returns>Returns a clone of the object.</returns> public PrefabListItem Clone() { var item = new PrefabListItem(); item.IsChecked = this.IsChecked; item.Name = this.Name; item.Prefab = this.Prefab; item.Weight = this.Weight; return item; }
/// <summary> /// Creates a clone of the object. /// </summary> /// <returns>Returns a clone of the object.</returns> public PrefabListItem Clone() { var item = new PrefabListItem(); item.IsChecked = this.IsChecked; item.Name = this.Name; item.Prefab = this.Prefab; item.Weight = this.Weight; return(item); }
/// <summary> /// Used to draw a single alternate prefab item in the alternate prefab list. /// </summary> /// <param name="alternate">The reference to the alternate prefab.</param> private void DrawAlternateItem(PrefabListItem alternate) { // if alternate parameter is null do nothing if (alternate == null) { return; } // setup button style to use for each item in the list var buttonStyle = new GUIStyle(GUI.skin.button) { alignment = TextAnchor.UpperCenter, imagePosition = ImagePosition.ImageAbove }; // get asset preview var assetPreview = alternate.Prefab == null ? null : AssetPreview.GetAssetPreview(alternate.Prefab); assetPreview = assetPreview == null ? AssetPreview.GetMiniTypeThumbnail(typeof(GameObject)) : assetPreview; GUILayout.BeginVertical(GUI.skin.box, GUILayout.MinWidth(154), GUILayout.MaxWidth(154)); // box // if there is something to show then show it if (!string.IsNullOrEmpty(alternate.Name) || alternate.Prefab != this.alternatePrefab) { GUILayout.BeginHorizontal(); // top name and update button // show the rule name above // GUILayout.Label(alternate.name); alternate.IsChecked = GUILayout.Toggle(alternate.IsChecked, new GUIContent(alternate.Name)); // provide a button to update the rule prefab to the currently selected prefab if (GUILayout.Button("S", GUILayout.ExpandWidth(false))) { Selection.objects = new Object[] { alternate.Prefab }; EditorGUIUtility.PingObject(alternate.Prefab); } // provide a button to update the rule prefab to the currently selected prefab if (this.alternatePrefab != null && alternate.Prefab != this.alternatePrefab && GUILayout.Button("U", GUILayout.ExpandWidth(false))) { alternate.Prefab = this.alternatePrefab; // rule.Alternates[index] = alternate; this.IsDirty = true; } GUILayout.EndHorizontal(); // top name and update button } // draw asset preview alternate.IsChecked = GUILayout.Toggle(alternate.IsChecked, new GUIContent(assetPreview), buttonStyle); GUILayout.EndVertical(); // box }