// public override void OnInspectorGUI() // { // component = (UITagButton) target; //// component.Normal = (GameObject)EditorGUILayout.ObjectField("Normal", component.Normal, typeof(GameObject), true); //// component.Choose = (GameObject)EditorGUILayout.ObjectField("Choose", component.Choose, typeof(GameObject), true); //// //// GUILayout.BeginHorizontal(); //// if (GUILayout.Button("Normal")) //// { //// component.SetToggleEditor(); //// } //// if (GUILayout.Button("Choose")) //// { //// component.SetToggleEditor(true); //// } //// GUILayout.EndHorizontal(); // // //base.OnInspectorGUI(); // if (!component.bInit) // { // component.bInit = true; // SetDefaultValue(component); // } // } private static void SetDefaultValue(UITagButton component) { if (component == null) { return; } if (component.targetGraphic != null) { component.targetGraphic.raycastTarget = true; } //component.SetToggleEditor(); }
public static new UITagButton AddComponent() { // QImageBox image = QImageBoxEditor.AddComponent(); // image.raycastTarget = true; // // QToggleButton component = Util.GetOrAddCompoment<QToggleButton>(image.CacheGameObject); // component.name = typeof(QToggleButton).Name.ToString(); //设置默认值 UITagButton component = UtilEditor.ExtensionComponentWhenCreate <UITagButton>(typeof(UITagButton).Name.ToString()); UIImage image = UtilEditor.GetOrAddCompoment <UIImage>(component.gameObject); component.targetGraphic = image; SetDefaultValue(component); return(component); }
public override void Show(UIState ui) { base.Show(ui); this.BeginModBrowserPopulateCheck(ui); this.RecalculateMenuObjects(); this.EnableTagButtons(); this.InfoDisplay.SetDefaultText("Click tags to filter the list. Right-click tags to filter without them."); UIElement elem; if (ReflectionHelpers.Get <UIElement>(ui, "uIElement", out elem)) { elem.Left.Pixels += UITagButton.ColumnWidth; elem.Recalculate(); } Promises.AddValidatedPromise <ModTagsPromiseArguments>(GetModTags.TagsReceivedPromiseValidator, (args) => { Timers.SetTimer("ModBrowserDefaultTagStates", 15, () => { if (this.MyUI != ui) { return(false); } bool isLoading; if (!ReflectionHelpers.Get(this.MyUI, "loading", out isLoading)) { LogHelpers.Warn("ModBrowserTagsMenuContext - No 'loading'."); return(false); } if (isLoading) { return(true); } else { UITagButton button = this.TagButtons["Misleading Info"]; button.SetTagState(-1); return(false); } }); return(true); }); }
//////////////// private void SetCurrentMod(UIState ui, string modName) { this.CurrentModName = modName; Promises.AddValidatedPromise <ModTagsPromiseArguments>(GetModTags.TagsReceivedPromiseValidator, (args) => { if (!args.Found) { LogHelpers.Warn(); return(false); } this.AllModTagsSnapshot = args.ModTags; ISet <string> netModTags = args.Found && args.ModTags.ContainsKey(modName) ? args.ModTags[modName] : new HashSet <string>(); bool hasNetTags = netModTags.Count > 0; //LogHelpers.Log( "SetCurrentMod modname: " + modName + ", modTags: " + string.Join(",", netModTags ) ); if (hasNetTags) { this.InfoDisplay.SetDefaultText("Do these tags look incorrect? If so, modify them."); this.FinishButton.SetModeReadOnly(); this.ResetButton.Disable(); } else { this.InfoDisplay.SetDefaultText("No tags set for this mod. Why not add some?"); this.FinishButton.SetModeSubmit(); } foreach (var kv in this.TagButtons) { string tagName = kv.Key; UITagButton button = kv.Value; bool hasTag = netModTags.Contains(tagName); if (!hasNetTags) { button.Enable(); } if (tagName == "Low Effort") { if (hasTag) { button.SetTagState(1); } else { string desc = this.GetModDataFromActiveMod(modName, "description"); if (string.IsNullOrEmpty(desc)) { string _ = ""; desc = this.GetModDescriptionFromUI(modName, ref _); } if (desc.Contains("Modify this file with a description of your mod.")) { button.SetTagState(1); } } } else { button.SetTagState(hasTag ? 1 : 0); } } return(false); }); }
//////////////// public override void OnTagStateChange(UITagButton tagButton) { this.FilterMods(); this.ResetButton.UpdateEnableState(); }
//////////////// public abstract void OnTagStateChange(UITagButton tagButton);