-
Notifications
You must be signed in to change notification settings - Fork 1
Information Flow, Architecture, and Animal Manager System
The primary components involved in the animal switch system are:
- Animal Manager prefab
- Animal Prefabs
- World Objects
- Skybox Manager Prefab
- Renderer Manager Prefab
- Environment Controllers
The Animal Manager prefab keeps track of all of the animals and their specific vision and movement parameters. The prefab has the AnimalManager.cs
script on it. The script exposes two events: VisionSwitch
and AnimalSwitch
that other scripts can subscribe to:
-
VisionSwitch
: any function that takes in aVisionParameters
object can be subscribed to this -
AnimalSwitch
: any function that takes in aAnimal
enum can be subscribed to this
AnimalManager.cs
has a function SwitchAnimal
that takes in an Animal
enum as a parameter and an optional boolean setAsNewAnimal
(which is by default true). setAsNewAnimal
, if true, sets the animal passed in as the new animal that is being explored, so that on button press, it will switch automatically between that animal and human. The SwitchAnimal
function can be called by another script whenever the animal needs to be switched. When it is called, SwitchAnimal
searches through its list of animals then invokes the VisionSwitch
and AnimalSwitch
events, passing in the appropriate VisionParameters
and Animal
parameters respectively.
VisionParameters
is a class containing vision parameters/information and movement parameters/information, respectively. VisionParameters.cs
can be found under Assets > Scripts > Vision
.
AnimalManager.cs
Through the inspector, drag in animal prefabs (prefabs with the AnimalController.cs
script on them) into the Animal Controllers list of AnimalManager.cs
These are per-animal prefabs that contain the vision and movement information for each specific animal.
AnimalController.cs
AnimalVision.cs
Add the AnimalController.cs
script onto a game object. The required AnimalVision.cs
script will be added automatically. Set the parameters on the AnimalVision.cs
script that are appropriate for that animal. Don't forget to set the animal type in AnimalController.cs
.
Then, drag in all of your animal prefabs into the Animal Controllers list of the AnimalManager.cs
script.
Sometimes, the vision effects you wish to apply should differ per object (e.g. UV is a per-object effect because the amount of UV light emitted is dependent on the object). These effects are material effects. To use material effects, you need a MaterialController.cs
on every object whose material you wish to change on animal switch.
MaterialController.cs
- Any material effects you wish to apply:
MaterialSwap.cs
UV.cs
Add MaterialController.cs
on each world object that you wish to change the material of. Then add the material effects that you want to apply.
Controls the skybox materials.
SkyboxController.cs
- Any skybox effects you wish to apply:
SkyboxSwap.cs
Controls the addition and deletion of renderer effects to the custom render pipeline.
To use a renderer effect in a scene, its corresponding script must be added to the scene's Renderer Manager.
RendererController.cs
- Any renderer effects you wish to apply:
-
RendererEffect.cs
: The template for renderer effects. Custom renderer effects inherit from this script. -
BlitEffect.cs
: A general purpose renderer effect for creating blit effects. It can be used on its own, or as a template for more specific blit effects -
ColorblindEffect.cs
: The script for the colorblind renderer effect.
-
Controls the environment based on animal switch. Connected to animal manager's AnimalSwitch
event.
-
SoundController.cs
: controls an audio source's settings -
LightController.cs
: controls a light source's settings
Attach the script on the relevant component. For example, attach SoundController.cs
to a game object with an audio source, LightController.cs
to a game object with a light. Add the settings associated with each animal as needed. If an animal is not provided, it will default to the original settings found on the source.
-
AnimalManager.cs
: Manages animal switching and notifying other scripts of animal switching -
AnimalController.cs
: Per-animal controller. Synthesizes information from an animal'sAnimalVision.cs
script so that the Animal Manager can access this information more easily. -
MaterialController.cs
: In charge of applying material changes to objects when animal has been switched -
RendererController.cs
: In charge of applying renderer effects to the render pipeline when animal has been switched. -
SkyboxController.cs
: In charge of applying material changes to skybox materials -
SoundController.cs
: In charge of switching sound settings on the assigned audio source -
LightController.cs
: In charge of switching light settings on the assigned light source
-
MaterialEffect.cs
: Inherited by all vision effects that affect a renderer's materials. -
RendererEffect.cs
: Inherited by all vision effects that are applied to the render pipeline and affect the camera. -
SkyboxEffect.cs
: Inherited by all vision effects that affect a skybox's materials. -
VisionParameters.cs
: class that holds all of an animal's vision information so that scripts can access that information on animal switch.
-
UV.cs
: A material effect. Inherits fromMaterialEffect.cs
. Applies UV false color to a renderer's materials by getting rid of a material's red channel, switching the green channel to the material's red channel, the blue channel to the green channel, and applying a UV amount to the blue channel. -
MaterialSwap.cs
: A material effect. Inherits fromMaterialEffect.cs
. Swaps out materials for the appropriate one based on animal type. -
SparkleShaderIntensity.cs
: A material effect. Used to control the sparkle shader. -
SkyboxSwap.cs
: A skybox effect. Inherits fromSkyboxEffec.cs
. Swaps out skybox materials. -
ColorblindEffect.cs
: A renderer effect. Applies the specified colorblindness to the render pipeline/camera.