Skip to content

Commit

Permalink
add two more overloads for pnlmenu toggle create, fix toggle group
Browse files Browse the repository at this point in the history
  • Loading branch information
lxymahatma committed Feb 12, 2023
1 parent 8a96539 commit 88473b9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/MelonBuildInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ internal static class MelonBuildInfo

public const string Author = "lxy";

public const string Version = "1.1.0";
public const string Version = "1.1.1";
}
}
40 changes: 31 additions & 9 deletions src/UICreate/ToggleCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool
public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, string parentName, ToggleGroup toggleGroup)
{
var toggle = CreateToggle(name, position, isEnabled, text, parentName);
toggleGroup.RegisterToggle(toggle.GetComponent<Toggle>());
toggle.GetComponent<Toggle>().group = toggleGroup;
return toggle;
}

Expand All @@ -79,7 +79,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool
public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, string parentName, int fontSize, Color textColor, ToggleGroup toggleGroup)
{
var toggle = CreateToggle(name, position, isEnabled, text, parentName, fontSize, textColor);
toggleGroup.RegisterToggle(toggle.GetComponent<Toggle>());
toggle.GetComponent<Toggle>().group = toggleGroup;
return toggle;
}

Expand All @@ -102,7 +102,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool
public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, string parentName, int fontSize, Color textColor, Color checkBoxColor, Color checkMarkColor, ToggleGroup toggleGroup)
{
var toggle = CreateToggle(name, position, isEnabled, text, parentName, fontSize, textColor, checkBoxColor, checkMarkColor);
toggleGroup.RegisterToggle(toggle.GetComponent<Toggle>());
toggle.GetComponent<Toggle>().group = toggleGroup;
return toggle;
}

Expand Down Expand Up @@ -149,7 +149,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool
public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, GameObject parent, ToggleGroup toggleGroup)
{
var toggle = CreateToggle(name, position, isEnabled, text, parent);
toggleGroup.RegisterToggle(toggle.GetComponent<Toggle>());
toggle.GetComponent<Toggle>().group = toggleGroup;
return toggle;
}

Expand All @@ -171,7 +171,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool
public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, GameObject parent, int fontSize, Color textColor, ToggleGroup toggleGroup)
{
var toggle = CreateToggle(name, position, isEnabled, text, parent, fontSize, textColor);
toggleGroup.RegisterToggle(toggle.GetComponent<Toggle>());
toggle.GetComponent<Toggle>().group = toggleGroup;
return toggle;
}

Expand All @@ -194,7 +194,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool
public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, GameObject parent, int fontSize, Color textColor, Color checkBoxColor, Color checkMarkColor, ToggleGroup toggleGroup)
{
var toggle = CreateToggle(name, position, isEnabled, text, parent, fontSize, textColor, checkBoxColor, checkMarkColor);
toggleGroup.RegisterToggle(toggle.GetComponent<Toggle>());
toggle.GetComponent<Toggle>().group = toggleGroup;
return toggle;
}

Expand Down Expand Up @@ -241,7 +241,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool
public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, Transform parent, ToggleGroup toggleGroup)
{
var toggle = CreateToggle(name, position, isEnabled, text, parent);
toggleGroup.RegisterToggle(toggle.GetComponent<Toggle>());
toggle.GetComponent<Toggle>().group = toggleGroup;
return toggle;
}

Expand All @@ -263,7 +263,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool
public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, Transform parent, int fontSize, Color textColor, ToggleGroup toggleGroup)
{
var toggle = CreateToggle(name, position, isEnabled, text, parent, fontSize, textColor);
toggleGroup.RegisterToggle(toggle.GetComponent<Toggle>());
toggle.GetComponent<Toggle>().group = toggleGroup;
return toggle;
}

Expand All @@ -286,7 +286,7 @@ public static unsafe GameObject CreateToggle(string name, Vector3 position, bool
public static unsafe GameObject CreateToggle(string name, Vector3 position, bool* isEnabled, string text, Transform parent, int fontSize, Color textColor, Color checkBoxColor, Color checkMarkColor, ToggleGroup toggleGroup)
{
var toggle = CreateToggle(name, position, isEnabled, text, parent, fontSize, textColor, checkBoxColor, checkMarkColor);
toggleGroup.RegisterToggle(toggle.GetComponent<Toggle>());
toggle.GetComponent<Toggle>().group = toggleGroup;
return toggle;
}

Expand Down Expand Up @@ -334,6 +334,28 @@ public static unsafe GameObject CreatePnlMenuToggle(string name, bool* isEnabled
return toggle;
}

/// <summary>
/// Create Toggle at PnlMenu with toggle group
/// </summary>
public static unsafe GameObject CreatePnlMenuToggle(string name, bool* isEnabled, string text, string parentName, ToggleGroup toggleGroup)
{
var toggle = CreatePnlMenuToggle(name, isEnabled, text);
toggle.transform.SetParent(GameObject.Find(parentName).transform);
toggle.GetComponent<Toggle>().group = toggleGroup;
return toggle;
}

/// <summary>
/// Create Toggle at PnlMenu with toggle group
/// </summary>
public static unsafe GameObject CreatePnlMenuToggle(string name, bool* isEnabled, string text, GameObject parent, ToggleGroup toggleGroup)
{
var toggle = CreatePnlMenuToggle(name, isEnabled, text);
toggle.transform.SetParent(parent.transform);
toggle.GetComponent<Toggle>().group = toggleGroup;
return toggle;
}

/// <summary>
/// Create Toggle at PnlMenu with custom fontsize and text color
/// </summary>
Expand Down

0 comments on commit 88473b9

Please sign in to comment.