Example #1
0
        /// <summary>
        /// Draws the object list of the shortcut type.
        /// </summary>
        /// <param name="shortcutType">Shortcut type to be drawn.</param>
        private void DrawTypeObjects(ShortcutType shortcutType)
        {
            var guids = AssetUtils.GetAssetsGuid(shortcutType.typeName);

            if (guids.Length == 0)
            {
                EditorGUILayout.HelpBox("There are no objects for the selected type.", MessageType.Info);
            }

            foreach (var guid in guids)
            {
                var exists = false;

                //Checks whether the asset exists.
                foreach (var guidOnItem in shortcutType.guids)
                {
                    if (guidOnItem == guid)
                    {
                        exists = true;
                        break;
                    }
                }

                //Check asset selection.
                EditorGUILayout.BeginHorizontal();
                var selected = EditorGUILayout.Toggle(exists, GUILayout.Width(30));
                EditorGUILayout.LabelField(AssetDatabase.GUIDToAssetPath(guid));
                EditorGUILayout.EndHorizontal();

                if (selected && !exists)
                {
                    shortcutType.guids.Add(guid);
                }
                else if (!selected && exists)
                {
                    shortcutType.guids.Remove(guid);
                }
            }

            //Removes any empty elements from objects.
            shortcutType.guids.Remove(string.Empty);
        }