Static gameobject to object (#181)

* static GameObject -> Object (just to remove warnings)
This commit is contained in:
AmazingAlek 2020-07-12 19:54:52 +02:00 committed by GitHub
parent e594e15ed0
commit bd3cf655c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 52 additions and 50 deletions

View File

@ -1,7 +1,7 @@
using System;
using OWML.Common.Menus;
using OWML.ModHelper.Events;
using UnityEngine;
using Object = UnityEngine.Object;
using UnityEngine.UI;
namespace OWML.ModHelper.Menus
@ -37,8 +37,8 @@ namespace OWML.ModHelper.Menus
public IModButton Copy()
{
var button = GameObject.Instantiate(Button);
GameObject.Destroy(button.GetComponent<SubmitAction>());
var button = Object.Instantiate(Button);
Object.Destroy(button.GetComponent<SubmitAction>());
var modButton = (IModButton)Activator.CreateInstance(GetType(), button, Menu);
modButton.Index = Index + 1;
return modButton;

View File

@ -85,8 +85,8 @@ namespace OWML.ModHelper.Menus
public IModComboInput Copy()
{
var copy = GameObject.Instantiate(ToggleElement);
GameObject.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
var copy = Object.Instantiate(ToggleElement);
Object.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
return new ModComboInput(copy, Menu, InputMenu, _inputHandler);
}

View File

@ -52,7 +52,7 @@ namespace OWML.ModHelper.Menus
layoutGroup.spacing = 0f;
var constantGraphics = layoutObject.GetComponentsInChildren<Graphic>(true);
layoutObject.transform.GetComponentInChildren<Text>(true).gameObject.SetActive(false);
var styleManager = GameObject.FindObjectOfType<UIStyleManager>();
var styleManager = Object.FindObjectOfType<UIStyleManager>();
var styleApplier = ModUIStyleApplier.ReplaceStyleApplier(toggle.gameObject);
Layout = new ModLayoutManager(layoutGroup, styleManager, styleApplier, scale, constantGraphics);
UpdateContents();
@ -148,7 +148,7 @@ namespace OWML.ModHelper.Menus
Layout.UpdateState();
Title = "";
Toggle.gameObject.SetActive(false);
GameObject.Destroy(Toggle.gameObject);
Object.Destroy(Toggle.gameObject);
}
public void DestroySelf()
@ -177,8 +177,8 @@ namespace OWML.ModHelper.Menus
public new IModInputCombinationElement Copy(string combination)
{
var copy = GameObject.Instantiate(Toggle);
GameObject.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
var copy = Object.Instantiate(Toggle);
Object.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
return new ModInputCombinationElement(copy, Menu, _popupMenu, _inputHandler, combination);
}
}

View File

@ -6,6 +6,7 @@ using UnityEngine.UI;
using UnityEngine;
using OWML.ModHelper.Input;
using System.Linq;
using Object = UnityEngine.Object;
namespace OWML.ModHelper.Menus
{
@ -31,7 +32,7 @@ namespace OWML.ModHelper.Menus
private GameObject CreateResetButton(Transform buttonsTransform)
{
var template = buttonsTransform.GetComponentInChildren<ButtonWithHotkeyImageElement>(true).gameObject;
var resetButtonObject = GameObject.Instantiate(template);
var resetButtonObject = Object.Instantiate(template);
resetButtonObject.name = "UIElement-ButtonReset";
resetButtonObject.transform.SetParent(buttonsTransform);
resetButtonObject.transform.SetSiblingIndex(1);
@ -44,7 +45,7 @@ namespace OWML.ModHelper.Menus
var layoutGroupNew = layoutObject.AddComponent<HorizontalLayoutGroup>();
layoutGroupNew.childForceExpandWidth = false;
layoutGroupNew.childControlWidth = false;
var styleManager = MonoBehaviour.FindObjectOfType<UIStyleManager>();
var styleManager = Object.FindObjectOfType<UIStyleManager>();
var styleApplier = layoutObject.AddComponent<ModUIStyleApplier>();
return new ModLayoutManager(layoutGroupNew, styleManager, styleApplier, scaleReference.localScale);
}
@ -55,7 +56,7 @@ namespace OWML.ModHelper.Menus
{
return;
}
var parentCopy = GameObject.Instantiate(menu.transform.parent.gameObject);
var parentCopy = Object.Instantiate(menu.transform.parent.gameObject);
parentCopy.AddComponent<DontDestroyOnLoad>();
_twoButtonPopup = parentCopy.transform.Find("TwoButton-Popup")?.GetComponent<PopupMenu>();
if (_twoButtonPopup == null)
@ -70,13 +71,13 @@ namespace OWML.ModHelper.Menus
var buttons = buttonsTransform.GetComponentsInChildren<Button>(true).ToList();
buttons.ForEach(button => button.navigation = new Navigation { mode = Navigation.Mode.None });
var tabbedNavigations = menuTransform.GetComponentsInChildren<TabbedNavigation>(true).ToList();
tabbedNavigations.ForEach(GameObject.Destroy);
tabbedNavigations.ForEach(Object.Destroy);
var resetButtonObject = CreateResetButton(buttonsTransform);
ModLayoutManager layout = null;
var inputObject = menuTransform.GetComponentInChildren<InputField>(true).gameObject; // InputField
GameObject.Destroy(inputObject.GetComponent<InputField>());
Object.Destroy(inputObject.GetComponent<InputField>());
foreach (Transform child in inputObject.transform)
{
if (child.name == "BorderImage")
@ -85,7 +86,7 @@ namespace OWML.ModHelper.Menus
}
else
{
GameObject.Destroy(child.gameObject);
Object.Destroy(child.gameObject);
}
}
@ -100,8 +101,8 @@ namespace OWML.ModHelper.Menus
var submitAction = resetButtonObject.GetComponent<SubmitAction>();
var imageElement = resetButtonObject.GetComponent<ButtonWithHotkeyImageElement>();
_inputMenu.Initialize(originalMenu, inputSelectable, submitAction, imageElement, layout, _inputHandler);
GameObject.Destroy(originalMenu);
GameObject.Destroy(_inputMenu.GetValue<Text>("_labelText").GetComponent<LocalizedText>());
Object.Destroy(originalMenu);
Object.Destroy(_inputMenu.GetValue<Text>("_labelText").GetComponent<LocalizedText>());
Initialize((Menu)_inputMenu);
}

View File

@ -28,7 +28,7 @@ namespace OWML.ModHelper.Menus
base.InitializeMenu();
if (_resetAction != null)
{
_resetAction.OnSubmitAction += this.InvokeReset;
_resetAction.OnSubmitAction += InvokeReset;
}
}

View File

@ -2,7 +2,7 @@
using OWML.Common;
using OWML.Common.Menus;
using OWML.ModHelper.Events;
using UnityEngine;
using Object = UnityEngine.Object;
using UnityEngine.UI;
namespace OWML.ModHelper.Menus
@ -23,10 +23,10 @@ namespace OWML.ModHelper.Menus
return;
}
var parent = menu.transform.parent.gameObject;
var parentCopy = GameObject.Instantiate(parent);
var parentCopy = Object.Instantiate(parent);
parentCopy.AddComponent<DontDestroyOnLoad>();
_inputMenu = parentCopy.transform.GetComponentInChildren<PopupInputMenu>(true);
GameObject.Destroy(_inputMenu.GetValue<Text>("_labelText").GetComponent<LocalizedText>());
Object.Destroy(_inputMenu.GetValue<Text>("_labelText").GetComponent<LocalizedText>());
Initialize((Menu)_inputMenu);
}

View File

@ -11,7 +11,7 @@ namespace OWML.ModHelper.Menus
public ModLayoutButton(Button button, IModMenu menu) : base(button, menu)
{
var scale = button.transform.localScale;
GameObject.Destroy(Button.GetComponentInChildren<Text>(true).gameObject);
Object.Destroy(Button.GetComponentInChildren<Text>(true).gameObject);
var layoutObject = new GameObject("LayoutGroup", typeof(RectTransform));
layoutObject.transform.SetParent(button.transform);
var target = layoutObject.AddComponent<Image>();
@ -24,7 +24,7 @@ namespace OWML.ModHelper.Menus
layoutGroup.childControlHeight = false;
layoutGroup.childForceExpandHeight = false;
layoutGroup.childForceExpandWidth = false;
var styleManager = GameObject.FindObjectOfType<UIStyleManager>();
var styleManager = Object.FindObjectOfType<UIStyleManager>();
var styleApplier = ModUIStyleApplier.ReplaceStyleApplier(Button.gameObject);
Layout = new ModLayoutManager(layoutGroup, styleManager, styleApplier, scale);
}

View File

@ -67,7 +67,7 @@ namespace OWML.ModHelper.Menus
continue;
}
child.gameObject.SetActive(false);
GameObject.Destroy(child.gameObject);
Object.Destroy(child.gameObject);
}
}

View File

@ -1,6 +1,6 @@
using OWML.Common.Menus;
using System;
using UnityEngine;
using Object = UnityEngine.Object;
namespace OWML.ModHelper.Menus
{
@ -44,8 +44,8 @@ namespace OWML.ModHelper.Menus
public IModNumberInput Copy()
{
var copy = GameObject.Instantiate(ToggleElement);
GameObject.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
var copy = Object.Instantiate(ToggleElement);
Object.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
return new ModNumberInput(copy, Menu, InputMenu);
}

View File

@ -2,7 +2,7 @@
using OWML.Common;
using OWML.Common.Menus;
using OWML.ModHelper.Events;
using UnityEngine;
using Object = UnityEngine.Object;
using UnityEngine.UI;
namespace OWML.ModHelper.Menus
@ -31,7 +31,7 @@ namespace OWML.ModHelper.Menus
if (localizedText != null)
{
Title = UITextLibrary.GetString(localizedText.GetValue<UITextType>("_textID"));
GameObject.Destroy(localizedText);
Object.Destroy(localizedText);
}
Menu.OnActivateMenu += OnActivateMenu;
Menu.OnDeactivateMenu += OnDeactivateMenu;
@ -89,7 +89,7 @@ namespace OWML.ModHelper.Menus
OwmlConsole.WriteLine("Warning: can't copy menu, it doesn't exist.");
return null;
}
var menu = GameObject.Instantiate(Menu, Menu.transform.parent);
var menu = Object.Instantiate(Menu, Menu.transform.parent);
var modMenu = new ModPopupMenu(OwmlConsole);
modMenu.Initialize(menu);
return modMenu;

View File

@ -8,10 +8,10 @@ namespace OWML.ModHelper.Menus
public class ModPromptButton : ModTitleButton, IModPromptButton
{
private ScreenPrompt _prompt;
private UITextType _textID;
private readonly UITextType _textId;
private readonly ButtonWithHotkeyImageElement _hotkeyButton;
public string DefaultTitle => UITextLibrary.GetString(_textID);
public string DefaultTitle => UITextLibrary.GetString(_textId);
public ScreenPrompt Prompt
{
get => _prompt;
@ -21,7 +21,7 @@ namespace OWML.ModHelper.Menus
_hotkeyButton.SetPrompt(value);
if (_prompt.GetText() != DefaultTitle)
{
GameObject.Destroy(Button.GetComponentInChildren<LocalizedText>());
Object.Destroy(Button.GetComponentInChildren<LocalizedText>());
}
}
}
@ -38,7 +38,7 @@ namespace OWML.ModHelper.Menus
_prompt.SetText(value);
if (value != DefaultTitle)
{
GameObject.Destroy(Button.GetComponentInChildren<LocalizedText>());
Object.Destroy(Button.GetComponentInChildren<LocalizedText>());
}
}
}
@ -52,7 +52,7 @@ namespace OWML.ModHelper.Menus
return;
}
_prompt = _hotkeyButton.GetValue<ScreenPrompt>("_screenPrompt");
_textID = Button.GetComponentInChildren<LocalizedText>(true)?.GetValue<UITextType>("_textID") ?? UITextType.None;
_textId = Button.GetComponentInChildren<LocalizedText>(true)?.GetValue<UITextType>("_textID") ?? UITextType.None;
}
}
}

View File

@ -28,8 +28,8 @@ namespace OWML.ModHelper.Menus
public IModSliderInput Copy()
{
var copy = GameObject.Instantiate(_element);
GameObject.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
var copy = Object.Instantiate(_element);
Object.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
return new ModSliderInput(copy, Menu);
}

View File

@ -44,10 +44,10 @@ namespace OWML.ModHelper.Menus
public new IModTabMenu Copy()
{
var tabButton = GameObject.Instantiate(TabButton, TabButton.transform.parent);
GameObject.Destroy(tabButton.GetComponentInChildren<LocalizedText>(true));
var tabButton = Object.Instantiate(TabButton, TabButton.transform.parent);
Object.Destroy(tabButton.GetComponentInChildren<LocalizedText>(true));
_text = tabButton.GetComponentInChildren<Text>(true);
var menu = GameObject.Instantiate(Menu, Menu.transform.parent);
var menu = Object.Instantiate(Menu, Menu.transform.parent);
tabButton.SetValue("_tabbedMenu", menu);
var modMenu = new ModTabMenu(OwmlConsole, _optionsMenu);
modMenu.Initialize(tabButton);

View File

@ -43,8 +43,8 @@ namespace OWML.ModHelper.Menus
public IModTextInput Copy()
{
var copy = GameObject.Instantiate(ToggleElement);
GameObject.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
var copy = Object.Instantiate(ToggleElement);
Object.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
return new ModTextInput(copy, Menu, InputMenu);
}

View File

@ -12,7 +12,7 @@ namespace OWML.ModHelper.Menus
get => _text != null ? _text.text : "";
set
{
GameObject.Destroy(Button.GetComponentInChildren<LocalizedText>());
Object.Destroy(Button.GetComponentInChildren<LocalizedText>());
_text.text = value;
}
}

View File

@ -34,8 +34,8 @@ namespace OWML.ModHelper.Menus
public virtual IModToggleInput Copy()
{
var copy = GameObject.Instantiate(Toggle);
GameObject.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
var copy = Object.Instantiate(Toggle);
Object.Destroy(copy.GetComponentInChildren<LocalizedText>(true));
return new ModToggleInput(copy, Menu);
}

View File

@ -77,7 +77,7 @@ namespace OWML.ModHelper.Menus
if (oldUIStyleApplier != null)
{
newUIStyleApplier.Initialize(oldUIStyleApplier);
GameObject.Destroy(oldUIStyleApplier);
Destroy(oldUIStyleApplier);
}
return newUIStyleApplier;
}

View File

@ -65,7 +65,7 @@ namespace OWML.ModHelper.Menus
private void CreateModMenuTemplate(IModOWMenu mainMenu)
{
var remapControlsButton = mainMenu.OptionsMenu.InputTab.GetTitleButton("UIElement-RemapControls");
var buttonTemplate = GameObject.Instantiate(remapControlsButton.Button);
var buttonTemplate = Object.Instantiate(remapControlsButton.Button);
buttonTemplate.gameObject.AddComponent<DontDestroyOnLoad>();
_modButtonTemplate = new ModTitleButton(buttonTemplate, mainMenu);
_modButtonTemplate.Button.enabled = false;
@ -73,7 +73,7 @@ namespace OWML.ModHelper.Menus
var submitActionMenu = remapControlsButton.Button.GetComponent<SubmitActionMenu>();
var rebindingMenu = submitActionMenu.GetValue<Menu>("_menuToOpen");
var rebindingCanvas = rebindingMenu.transform.parent;
_modMenuTemplate = GameObject.Instantiate(rebindingCanvas);
_modMenuTemplate = Object.Instantiate(rebindingCanvas);
_modMenuTemplate.gameObject.AddComponent<DontDestroyOnLoad>();
}
@ -85,7 +85,7 @@ namespace OWML.ModHelper.Menus
modsTab.Menu.GetValue<TooltipDisplay>("_tooltipDisplay").GetComponent<Text>().color = Color.clear;
options.AddTab(modsTab);
var modMenuTemplate = _modMenuTemplate.GetComponentInChildren<Menu>(true);
var modMenuCopy = GameObject.Instantiate(modMenuTemplate, _modMenuTemplate.transform);
var modMenuCopy = Object.Instantiate(modMenuTemplate, _modMenuTemplate.transform);
var modInputCombinationElementTemplate = new ModInputCombinationElement(options.InputTab.ToggleInputs[0].Copy().Toggle,
_menus.InputCombinationMenu, _menus.InputCombinationElementMenu, _inputHandler);
_menus.InputCombinationMenu.Initialize(modMenuCopy, modInputCombinationElementTemplate);
@ -107,7 +107,7 @@ namespace OWML.ModHelper.Menus
var toggleTemplate = options.InputTab.ToggleInputs[0];
var sliderTemplate = options.InputTab.SliderInputs[0];
var modMenuTemplate = _modMenuTemplate.GetComponentInChildren<Menu>(true);
var modMenuCopy = GameObject.Instantiate(modMenuTemplate, _modMenuTemplate.transform);
var modMenuCopy = Object.Instantiate(modMenuTemplate, _modMenuTemplate.transform);
var textInputTemplate = new ModTextInput(toggleTemplate.Copy().Toggle, modConfigMenu, _menus.InputMenu);
textInputTemplate.Hide();
var comboInputTemplate = new ModComboInput(toggleTemplate.Copy().Toggle, modConfigMenu, _menus.InputCombinationMenu, _inputHandler);

View File

@ -16,6 +16,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gamepad/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gameplay/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=globalgamemanagers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=hotkey/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=libraryfolders/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=openvr/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=OWML/@EntryIndexedValue">True</s:Boolean>