public T Convert <T>(XmlNode node) where T : class { var textArea = EasyIMGUI.TextArea(); foreach (XmlAttribute nodeAttribute in node.Attributes) { if (nodeAttribute.Name == "Id") { textArea.Id = nodeAttribute.Value; } else if (nodeAttribute.Name == "Text") { textArea.Text(nodeAttribute.Value); } } return(textArea as T); }
protected override void Init() { PackageMakerState.InitState(); var hashSet = new HashSet <string>(); if (mPackageVersion.IncludeFileOrFolders.Count == 0 && mPackageVersion.InstallPath.EndsWith("/")) { hashSet.Add(mPackageVersion.InstallPath.Remove(mPackageVersion.InstallPath.Length - 1)); } foreach (var packageIncludeFileOrFolder in mPackageVersion.IncludeFileOrFolders) { hashSet.Add(packageIncludeFileOrFolder); } _assetTree = new AssetTree(); _assetTreeGUI = new AssetTreeIMGUI(_assetTree.Root); var guids = AssetDatabase.FindAssets(string.Empty); int i = 0, l = guids.Length; for (; i < l; ++i) { _assetTree.AddAsset(guids[i], hashSet); } RootLayout = new VerticalLayout("box"); var editorView = EasyIMGUI.Vertical().Parent(RootLayout); var uploadingView = new VerticalLayout().Parent(RootLayout); // 当前版本号 var versionLine = EasyIMGUI.Horizontal().Parent(editorView); EasyIMGUI.Label().Text("当前版本号").Width(100).Parent(versionLine); EasyIMGUI.Label().Text(mPackageVersion.Version).Width(100).Parent(versionLine); // 发布版本号 var publishedVersionLine = new HorizontalLayout().Parent(editorView); EasyIMGUI.Label().Text("发布版本号") .Width(100) .Parent(publishedVersionLine); EasyIMGUI.TextField() .Text(mPublishVersion) .Width(100) .Parent(publishedVersionLine) .Content.Bind(v => mPublishVersion = v); // 类型 var typeLine = EasyIMGUI.Horizontal().Parent(editorView); EasyIMGUI.Label().Text("类型").Width(100).Parent(typeLine); var packageType = new EnumPopupView(mPackageVersion.Type).Parent(typeLine); var accessRightLine = EasyIMGUI.Horizontal().Parent(editorView); EasyIMGUI.Label().Text("权限").Width(100).Parent(accessRightLine); var accessRight = new EnumPopupView(mPackageVersion.AccessRight).Parent(accessRightLine); EasyIMGUI.Label().Text("发布说明:").Width(150).Parent(editorView); var releaseNote = EasyIMGUI.TextArea().Width(245) .Parent(editorView); // 文件选择部分 EasyIMGUI.Label().Text("插件目录: " + mPackageVersion.InstallPath) .Parent(editorView); EasyIMGUI.Custom().OnGUI(() => { _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition); _assetTreeGUI.DrawTreeLayout(); EditorGUILayout.EndScrollView(); }).Parent(editorView); PackageMakerState.InEditorView.BindWithInitialValue(value => { editorView.Visible = value; }) .AddTo(mDisposableList); if (User.Logined) { EasyIMGUI.Button() .Text("发布") .OnClick(() => { var includedPaths = new List <string>(); _assetTree.Root.Traverse(data => { if (data != null && data.isSelected) { includedPaths.Add(data.fullPath); return(false); } return(true); }); mPackageVersion.IncludeFileOrFolders = includedPaths; mPackageVersion.Readme.content = releaseNote.Content.Value; mPackageVersion.AccessRight = (PackageAccessRight)accessRight.ValueProperty.Value; mPackageVersion.Type = (PackageType)packageType.ValueProperty.Value; mPackageVersion.Version = mPublishVersion; mControllerNode.SendCommand(new PublishPackageCommand(mPackageVersion)); }).Parent(editorView); } var notice = new LabelViewWithRect("", 100, 200, 200, 200).Parent(uploadingView); PackageMakerState.NoticeMessage .BindWithInitialValue(value => { notice.Content.Value = value; }).AddTo(mDisposableList); PackageMakerState.InUploadingView.BindWithInitialValue(value => { uploadingView.Visible = value; }) .AddTo(mDisposableList); }
private void OnEnable() { mRootLayout = new VerticalLayout("box"); EasyIMGUI.Space() .Parent(mRootLayout); var markTypeLine = EasyIMGUI.Horizontal() .Parent(mRootLayout); EasyIMGUI.Label().Text(LocaleText.MarkType) .FontSize(12) .Width(60) .Parent(markTypeLine); var enumPopupView = new EnumPopupView(mBindScript.MarkType) .Parent(markTypeLine); enumPopupView.ValueProperty.Bind(newValue => { mBindScript.MarkType = (BindType)newValue; OnRefresh(); }); EasyIMGUI.Space() .Parent(mRootLayout); EasyIMGUI.Custom().OnGUI(() => { if (mBindScript.CustomComponentName == null || string.IsNullOrEmpty(mBindScript.CustomComponentName.Trim())) { mBindScript.CustomComponentName = mBindScript.name; } }).Parent(mRootLayout); mComponentLine = EasyIMGUI.Horizontal(); EasyIMGUI.Label().Text(LocaleText.Type) .Width(60) .FontSize(12) .Parent(mComponentLine); if (mBindScript.MarkType == BindType.DefaultUnityElement) { var components = mBindScript.GetComponents <Component>(); var componentNames = components.Where(c => !(c is AbstractBind)) .Select(c => c.GetType().FullName) .ToArray(); var componentNameIndex = 0; componentNameIndex = componentNames.ToList() .FindIndex((componentName) => componentName.Contains(mBindScript.ComponentName)); if (componentNameIndex == -1 || componentNameIndex >= componentNames.Length) { componentNameIndex = 0; } mBindScript.ComponentName = componentNames[componentNameIndex]; new PopupView(componentNameIndex, componentNames) .Parent(mComponentLine) .IndexProperty.Bind((index) => { mBindScript.ComponentName = componentNames[index]; }); } mComponentLine.Parent(mRootLayout); EasyIMGUI.Space() .Parent(mRootLayout); var belongsTo = EasyIMGUI.Horizontal() .Parent(mRootLayout); EasyIMGUI.Label().Text(LocaleText.BelongsTo) .Width(60) .FontSize(12) .Parent(belongsTo); EasyIMGUI.Label().Text(CodeGenUtil.GetBindBelongs2(target as AbstractBind)) .Width(200) .FontSize(12) .Parent(belongsTo); EasyIMGUI.Button() .Text(LocaleText.Select) .OnClick(() => { Selection.objects = new Object[] { CodeGenUtil.GetBindBelongs2GameObject(target as AbstractBind) }; }) .Width(60) .Parent(belongsTo); mClassnameLine = new HorizontalLayout(); EasyIMGUI.Label().Text(LocaleText.ClassName) .Width(60) .FontSize(12) .Parent(mClassnameLine); EasyIMGUI.TextField().Text(mBindScript.CustomComponentName) .Parent(mClassnameLine) .Content.Bind(newValue => { mBindScript.CustomComponentName = newValue; }); mClassnameLine.Parent(mRootLayout); EasyIMGUI.Space() .Parent(mRootLayout); EasyIMGUI.Label().Text(LocaleText.Comment) .FontSize(12) .Parent(mRootLayout); EasyIMGUI.Space() .Parent(mRootLayout); EasyIMGUI.TextArea() .Text(mBindScript.Comment) .Height(100) .Parent(mRootLayout) .Content.Bind(newValue => mBindScript.CustomComment = newValue); var bind = target as AbstractBind; var rootGameObj = CodeGenUtil.GetBindBelongs2GameObject(bind); if (rootGameObj.transform.GetComponent("ILKitBehaviour")) { } else if (rootGameObj.transform.IsUIPanel()) { EasyIMGUI.Button() .Text(LocaleText.Generate + " " + CodeGenUtil.GetBindBelongs2(bind)) .OnClick(() => { var rootPrefabObj = PrefabUtility.GetPrefabParent(rootGameObj); UICodeGenerator.DoCreateCode(new[] { rootPrefabObj }); }) .Height(30) .Parent(mRootLayout); } else if (rootGameObj.transform.IsViewController()) { EasyIMGUI.Button() .Text(LocaleText.Generate + " " + CodeGenUtil.GetBindBelongs2(bind)) .OnClick(() => { CreateViewControllerCode.DoCreateCodeFromScene(bind.gameObject); }) .Height(30) .Parent(mRootLayout); } OnRefresh(); }