/// <summary> /// Creates a new UBuildAction of the given type. /// </summary> /// <typeparam name='T'> /// The type of action to create. /// </typeparam> public static T Create <T>() where T : UTAction { UTDoc doc = UTDoc.GetFor(typeof(T)); var result = UTils.CreateAssetOfType <T>(doc.title); result.CreatedWithActionVersion = ActionVersion; return(result); }
protected virtual void DrawAll() { var type = target.GetType(); var fields = type.GetFields(); var groups = UTInspectorGroups.GetFor(type).groups; Array.Sort(fields, delegate(FieldInfo field1, FieldInfo field2) { return(SortFields(field1, field2, groups)); }); bool firstGroup = true; string currentGroup = ""; RenderActionHead(type); foreach (var field in fields) { if (field.IsPublic && !field.IsStatic) { if (!IsVisible(field)) { continue; // skip it. } var utDoc = UTDoc.GetFor(field); UTInspectorHint utHint = UTInspectorHint.GetFor(field); GUIContent label = new GUIContent(utDoc.title + (utHint.required || utHint.arrayNotEmpty ? " *" : ""), utDoc.description); if (utHint.group != currentGroup || firstGroup) { firstGroup = false; currentGroup = utHint.group; EditorGUILayout.Space(); if (!string.IsNullOrEmpty(currentGroup)) { GUILayout.Label(currentGroup, UTEditorResources.GroupStyle); } } string msg; if (!UTRequiresLicenseAttribute.HasRequiredLicense(field, out msg)) { // disable fields which require licenses that are not currently installed GUI.enabled = false; } DrawProperty(label, field); GUI.enabled = true; } } }
protected void RenderActionHead(Type type) { // new type var utDoc = UTDoc.GetFor(type); var utDefaultAction = UTDefaultAction.GetFor(type); GUIContent title = new GUIContent(utDoc.title); GUILayout.Label(title, UTEditorResources.TitleStyle); string url = utDoc.helpUrl; if (string.IsNullOrEmpty(url) && utDefaultAction != null) { var html = Regex.Replace(utDoc.title, "[^a-zA-Z0-9]", "_").ToLower() + ".html"; url = "/" + html; } if (!string.IsNullOrEmpty(url)) { Rect titleRect = GUILayoutUtility.GetLastRect(); Rect helpRect = new Rect(titleRect.xMax - 20, titleRect.yMin, 20, titleRect.height); if (GUI.Button(helpRect, UTEditorResources.HelpIcon, UTEditorResources.HelpButtonStyle)) { OpenHelp(url); } } if (!string.IsNullOrEmpty(utDoc.description)) { EditorGUILayout.HelpBox(utDoc.description, MessageType.None, true); } string msg; if (!UTRequiresLicenseAttribute.HasRequiredLicense(type, out msg)) { EditorGUILayout.HelpBox("This action requires the following licenses that are not currently installed: " + msg, MessageType.Warning, true); } }