blob: f5ccb87bc04910438887f535e2acc257b23326ae (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* ---------------------------------------
* Author: Martin Pane (martintayx@gmail.com) (@tayx94)
* Collaborators: Lars Aalbertsen (@Rockylars)
* Project: Graphy - Ultimate Stats Monitor
* Date: 04-Jan-18
* Studio: Tayx
*
* This project is released under the MIT license.
* Attribution is not required, but it is always welcomed!
* -------------------------------------*/
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.UI;
namespace Tayx.Graphy.Utils
{
public static class G_ExtensionMethods
{
/* ----- TODO: ----------------------------
* Add summaries to the functions.
* --------------------------------------*/
#region Methods -> Extension Methods
/// <summary>
/// Functions as the SetActive function in the GameObject class, but for a list of them.
/// </summary>
/// <param name="gameObjects">
/// List of GameObjects.
/// </param>
/// <param name="active">
/// Wether to turn them on or off.
/// </param>
public static List<GameObject> SetAllActive(this List<GameObject> gameObjects, bool active)
{
foreach (var gameObj in gameObjects)
{
gameObj.SetActive(active);
}
return gameObjects;
}
public static List<Image> SetOneActive(this List<Image> images, int active)
{
for (int i = 0; i < images.Count; i++)
{
images[i].gameObject.SetActive(i == active);
}
return images;
}
public static List<Image> SetAllActive(this List<Image> images, bool active)
{
foreach (var image in images)
{
image.gameObject.SetActive(active);
}
return images;
}
#endregion
}
}
|