> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor/ks.reactor.ksscriptlist-2.md).

# Class ksScriptList\<Parent, Script>

Namespace: [KS.Reactor](/reactor/api-reference/ks.reactor.md)\
Assembly: KSCommon.dll

A templated list of scripts.

```csharp
public class ksScriptList<Parent, Script> : IEnumerable<Script>, IEnumerable where Parent : class where Script : ksScript<Parent, Script>
```

#### Type Parameters

`Parent`

The type the scripts are attached to.

`Script`

The script type.

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [ksScriptList\<Parent, Script>](/reactor/api-reference/ks.reactor/ks.reactor.ksscriptlist-2.md)

#### Implements

[IEnumerable\<Script>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Properties

### Count <a href="#ks_reactor_ksscriptlist_2_count" id="ks_reactor_ksscriptlist_2_count"></a>

Number of scripts in the list.

```csharp
public int Count { get; }
```

#### Property Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Initialized <a href="#ks_reactor_ksscriptlist_2_initialized" id="ks_reactor_ksscriptlist_2_initialized"></a>

Are the scripts initialized? If true, new scripts will be initialized when they are attached.

```csharp
public bool Initialized { get; }
```

#### Property Value

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### this\[int] <a href="#ks_reactor_ksscriptlist_2_item_system_int32" id="ks_reactor_ksscriptlist_2_item_system_int32"></a>

Access the list by index.

```csharp
public Script this[int index] { get; }
```

#### Property Value

Script

## Methods

### Attach(Script) <a href="#ks_reactor_ksscriptlist_2_attach__1" id="ks_reactor_ksscriptlist_2_attach__1"></a>

Attaches a script. If the script is already attached somewhere, it is detached first.

```csharp
public void Attach(Script script)
```

#### Parameters

`script` Script

Script to attach.

### Detach(Script) <a href="#ks_reactor_ksscriptlist_2_detach__1" id="ks_reactor_ksscriptlist_2_detach__1"></a>

Detaches a script.

```csharp
public bool Detach(Script script)
```

#### Parameters

`script` Script

Script to detach.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the script was found.

### Detach\<T>() <a href="#ks_reactor_ksscriptlist_2_detach__1" id="ks_reactor_ksscriptlist_2_detach__1"></a>

Detaches a script of the template type.

```csharp
public T Detach<T>() where T : class
```

#### Returns

T

Removed script, or null if no script of that type was found.

#### Type Parameters

`T`

### DetachAll\<T>(bool) <a href="#ks_reactor_ksscriptlist_2_detachall__1_system_boolean" id="ks_reactor_ksscriptlist_2_detachall__1_system_boolean"></a>

Detaches all scripts of the template type.

```csharp
public void DetachAll<T>(bool allowAttachingScripts = false) where T : class
```

#### Parameters

`allowAttachingScripts` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

When false new scripts cannot be attached while other scripts are being removed.

#### Type Parameters

`T`

### DetachAll(bool) <a href="#ks_reactor_ksscriptlist_2_detachall_system_boolean" id="ks_reactor_ksscriptlist_2_detachall_system_boolean"></a>

Detaches all scripts.

```csharp
public void DetachAll(bool allowAttachingScripts = false)
```

#### Parameters

`allowAttachingScripts` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

When false new scripts cannot be attached while other scripts are being removed.

### Get\<T>() <a href="#ks_reactor_ksscriptlist_2_get__1" id="ks_reactor_ksscriptlist_2_get__1"></a>

Gets the first script of type T or null if not found.

```csharp
public T Get<T>() where T : class
```

#### Returns

T

A script of the template type, or null if the script is not found.

#### Type Parameters

`T`

### GetAll\<T>() <a href="#ks_reactor_ksscriptlist_2_getall__1" id="ks_reactor_ksscriptlist_2_getall__1"></a>

Gets all scripts of type T.

```csharp
public List<T> GetAll<T>() where T : class
```

#### Returns

[List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)\<T>

Script list.

#### Type Parameters

`T`

### GetEnumerator() <a href="#ks_reactor_ksscriptlist_2_getenumerator" id="ks_reactor_ksscriptlist_2_getenumerator"></a>

Gets the enumerator for the list.

```csharp
public IEnumerator<Script> GetEnumerator()
```

#### Returns

[IEnumerator](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1)\<Script>
