private void Start() { if (canActivate) { activatingPlatformBehaviour = GetComponent <ActivatingPlatformBehaviour>(); } if (canMove) { movingPlatformBehaviour = GetComponent <MovingPlatformBehaviour>(); } if (canRotate) { rotatingPlatformBehaviour = GetComponent <RotatingPlatformBehaviour>(); } }
public void AddOrRemoveBehaviours(int behaviourIndex, bool isAdding) { switch (behaviourIndex) { case 0: if (isAdding) { activatingPlatformBehaviour = gameObject.AddComponent <ActivatingPlatformBehaviour>(); canActivate = true; } else { DestroyImmediate(activatingPlatformBehaviour); canActivate = false; } break; case 1: if (isAdding) { rotatingPlatformBehaviour = gameObject.AddComponent <RotatingPlatformBehaviour>(); canRotate = true; } else { DestroyImmediate(rotatingPlatformBehaviour); canRotate = false; } break; case 2: if (isAdding) { movingPlatformBehaviour = gameObject.AddComponent <MovingPlatformBehaviour>(); canMove = true; } else { DestroyImmediate(movingPlatformBehaviour); canMove = false; } break; } }