public static void CopyToClipboard(string str) { TextEditor te = new TextEditor(); te.text = str; te.OnFocus(); te.Copy(); }
static void OnCopy(EventContext context) { TextEditor te = new TextEditor(); #if (UNITY_5_3 || UNITY_5_4) te.text = (string)context.data; #else te.content = new GUIContent((string)context.data); #endif te.OnFocus(); te.Copy(); }
/// <summary> /// /// </summary> /// <param name="textField"></param> /// <param name="value"></param> public static void OnCopy(InputTextField textField, string value) { TextEditor te = new TextEditor(); #if UNITY_5_3_OR_NEWER te.text = value; #else te.content = new GUIContent(value); #endif te.OnFocus(); te.Copy(); }
//绘制窗口时调用 void OnGUI () { GUILayout.TextArea (textShow); if (GUILayout.Button ("复制代码", GUILayout.Width (200))) { TextEditor te = new TextEditor(); te.content = new GUIContent(textShow); te.OnFocus(); te.Copy(); this.ShowNotification(new GUIContent("代码已复制")); } }
public override void OnInspectorGUI() { GUILayout.BeginHorizontal(); if (GUILayout.Button("拷贝到剪贴板")) { List<NpcConfig> bornPoints = new List<NpcConfig>(); configs.transform.GetComponentsInChildren<NpcConfig>(true, bornPoints); StringBuilder sb = new StringBuilder(); for (int i = 0; i < bornPoints.Count; i++) { sb.AppendFormat("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}", bornPoints[i].CampId, bornPoints[i].ActorId, bornPoints[i].transform.position.x, bornPoints[i].transform.position.z, bornPoints[i].transform.rotation.eulerAngles.y, bornPoints[i].Level, bornPoints[i].IsPassive); sb.AppendLine(); } string text = sb.ToString(); TextEditor editor = new TextEditor(); //editor.text = text; editor.content = new GUIContent(text); editor.OnFocus(); editor.Copy(); } GUILayout.EndHorizontal(); }
/// <summary> /// Notification of the input field gaining selection. /// </summary> protected void OnSelectEvent () { selection = this; if (mDoInit) Init(); if (label != null && NGUITools.GetActive(this)) { label.color = activeTextColor; #if MOBILE if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android #if UNITY_WP8 || Application.platform == RuntimePlatform.WP8Player #endif #if UNITY_BLACKBERRY || Application.platform == RuntimePlatform.BB10Player #endif ) { mKeyboard = (inputType == InputType.Password) ? TouchScreenKeyboard.Open(mValue, TouchScreenKeyboardType.Default, false, false, true) : TouchScreenKeyboard.Open(mValue, (TouchScreenKeyboardType)((int)keyboardType), inputType == InputType.AutoCorrect, label.multiLine); } else #endif { Input.imeCompositionMode = IMECompositionMode.On; Input.compositionCursorPos = (UICamera.current != null && UICamera.current.cachedCamera != null) ? UICamera.current.cachedCamera.WorldToScreenPoint(label.worldCorners[0]) : label.worldCorners[0]; #if !MOBILE mEditor = new TextEditor(); mEditor.content = new GUIContent(mValue); mEditor.OnFocus(); mEditor.MoveTextEnd(); #endif mDrawStart = 0; mDrawEnd = 0; } UpdateLabel(); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); property.isExpanded = EditorGUI.Foldout(new Rect(position.x, position.y, 80, c_FieldHeight), property.isExpanded, label); if (property.isExpanded) { float w = position.width; position.width = c_LabelWidth; position.height = c_FieldHeight; float x = position.x; float y = position.y; EditorGUI.LabelField(position, label); InplaceSkillInfo info = property.serializedObject.targetObject as InplaceSkillInfo; Dictionary<int, InplaceSkillInfo.InplaceSkillPropertyInfoGroup> dict = info.Properties; foreach (var pair in dict) { int skillId = pair.Key; var group = pair.Value; position.x = x; position.y += c_FieldHeight; group.IsFoldOut = EditorGUI.Foldout(position, group.IsFoldOut, "============<" + skillId + ">============"); if (group.IsFoldOut) { //技能可视编辑特性部分 if (null != group.PropertyList) { string lastGroup = string.Empty; foreach (var p in group.PropertyList) { position.x = x; position.y += c_FieldHeight; position.width = c_LabelWidth; if (lastGroup == p.Group) { EditorGUI.LabelField(position, string.Empty); } else { EditorGUI.LabelField(position, GetIndentLabel(p.Group)); } position.x += c_LabelWidth; position.width = 160; EditorGUI.LabelField(position, null == p.Key ? string.Empty : p.Key); var prop = p.Property; if (null != prop && prop.Value is AnimationCurve) { float tx = position.x; position.x += 160; EditorGUI.BeginChangeCheck(); object v = EditorGUI.CurveField(position, prop.Value as AnimationCurve); if (EditorGUI.EndChangeCheck()) { prop.Value = v; } position.x = tx + 120; position.width = 40; if (GUI.Button(position, "拷贝")) { AnimationCurve curve = v as AnimationCurve; if (null != curve) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < curve.keys.Length; ++i) { Keyframe key = curve.keys[i]; sb.AppendFormat("keyframe({0},{1},{2},{3});", key.time, key.value, key.inTangent, key.outTangent); sb.AppendLine(); } string text = sb.ToString(); TextEditor editor = new TextEditor(); editor.text = text; //editor.content = new GUIContent(text); editor.OnFocus(); editor.Copy(); } } } else { position.x += 160; EditProperty(position, p.Property); } lastGroup = p.Group; } } //技能资源(这里就不允许新加资源了,只能修改) TableConfig.Skill skillCfg = TableConfig.SkillProvider.Instance.GetSkill(skillId); if (null != skillCfg) { position.x = x; position.y += c_FieldHeight; position.width = c_LabelWidth; EditorGUI.LabelField(position, "=================="); position.x += c_LabelWidth; position.width = 160; EditorGUI.LabelField(position, "SkillResources"); position.x += 160; EditorGUI.LabelField(position, "============"); bool first = true; Dictionary<string, string> modifiedResources = new Dictionary<string, string>(); foreach (var resPair in skillCfg.resources) { string key = resPair.Key; string path = resPair.Value; position.x = x; position.y += c_FieldHeight; position.width = c_LabelWidth - 80; if (first) { EditorGUI.LabelField(position, ">>>resource"); } else { EditorGUI.LabelField(position, string.Empty); } first = false; position.width = 80; position.x += c_LabelWidth - 80; EditorGUI.LabelField(position, key); position.width = 160; position.x += 80; string[] guids = AssetDatabase.FindAssets("t:Prefab," + Path.GetFileName(path)); Object v = null; for (int i = 0; i < guids.Length; ++i) { string p = AssetDatabase.GUIDToAssetPath(guids[i]); if (p.Contains("Resources/" + path)) { v = AssetDatabase.LoadAssetAtPath<GameObject>(p); break; } } EditorGUI.BeginChangeCheck(); v = EditorGUI.ObjectField(position, v, typeof(GameObject), false); if (EditorGUI.EndChangeCheck()) { string respath = AssetDatabase.GetAssetPath(v.GetInstanceID()); int startIndex = respath.IndexOf(c_Resources); if (startIndex >= 0) { path = respath.Substring(startIndex + c_Resources.Length, respath.Length - startIndex - c_Resources.Length - c_Ext.Length); } else { path = respath; } modifiedResources.Add(key, path); } position.width = w - c_LabelWidth - 160; position.x += 160; EditorGUI.LabelField(position, path); } foreach (var resPair in modifiedResources) { skillCfg.resources[resPair.Key] = resPair.Value; } } } } } EditorGUI.EndProperty(); }
public override void OnInspectorGUI() { DrawDefaultInspector(); if (GUILayout.Button("拷贝到剪贴板")) { PrintCurve p = target as PrintCurve; AnimationCurve curve = p.Curve as AnimationCurve; if (null != curve) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < curve.keys.Length; ++i) { Keyframe key = curve.keys[i]; sb.AppendFormat("keyframe({0},{1},{2},{3});", key.time, key.value, key.inTangent, key.outTangent); sb.AppendLine(); } string text = sb.ToString(); TextEditor editor = new TextEditor(); editor.text = text; //editor.content = new GUIContent(text); editor.OnFocus(); editor.Copy(); } } }
public override void OnInspectorGUI() { DrawDefaultInspector(); if (GUILayout.Button("拷贝到剪贴板")) { InplaceSkillInfo info = target as InplaceSkillInfo; if (null != info) { var props = info.Properties; StringBuilder sb = new StringBuilder(); foreach (var pair in props) { int skillId = pair.Key; var group = pair.Value; sb.AppendFormat("========================dsl:{0}========================", skillId); sb.AppendLine(); if (null != group.PropertyList) { string lastGroup = string.Empty; foreach (var prop in group.PropertyList) { if (!string.IsNullOrEmpty(lastGroup) && lastGroup != prop.Group) { sb.AppendLine(); } if (null != prop.Property && null != prop.Property.Value && !(prop.Property.Value is AnimationCurve)) { sb.AppendFormat("{0}:{1}\t{2}", prop.Group, prop.Key, prop.Property.Value.ToString()); sb.AppendLine(); } else { sb.AppendFormat("{0}:{1}", prop.Group, prop.Key); sb.AppendLine(); } lastGroup = prop.Group; } } sb.AppendLine(); TableConfig.Skill skillCfg = TableConfig.SkillProvider.Instance.GetSkill(skillId); if (null != skillCfg) { sb.AppendLine("=====================SkillResources====================="); foreach (var resPair in skillCfg.resources) { sb.AppendFormat("{0}\t{1}\t{2}", skillId, resPair.Key, resPair.Value); sb.AppendLine(); } sb.AppendLine("====================EndSkillResources==================="); } } string text = sb.ToString(); TextEditor editor = new TextEditor(); editor.text = text; //editor.content = new GUIContent(text); editor.OnFocus(); editor.Copy(); } } }
private void CopyEditedSkillsToClipboard() { SaveEditedSkills(HomePath.GetAbsolutePath("../../../edit_skills_bak.txt")); string text = GetEditedSkillsText(); TextEditor editor = new TextEditor(); editor.text = text; //editor.content = new GUIContent(text); editor.OnFocus(); editor.Copy(); }