<!-- Page: https://rustic-game-engine.pages.dev/docs/api/environment/get-environment -->

# Game.scene.getEnvironment()

[Scene environment](https://rustic-game-engine.pages.dev/markdown/api/environment.md)

## Compatibility

**Supported languages:** C, C++, C#, Python, JavaScript, Lua 5.4, Luau, Java, PHP and HTML/inline JavaScript (binding spellings and return shapes differ).

Use a compatible native engine build and the language tools required by your binding. This does not establish browser/mobile export or release qualification for every OS.

The signature below is the shared reference notation; language examples show the actual binding syntax. Question marks mark optional arguments and explicit defaults are shown where recorded. Do not copy reference notation as a typed declaration.

See [Feature status and compatibility](https://rustic-game-engine.pages.dev/markdown/reference/compatibility.md) for API 1.0/1.1 and per-method restrictions. Engine release tags and Docs v0.1 are independent versions.

## Signature

`Game.scene.getEnvironment()`

## Setup and usage

Call during Start or a later gameplay callback. Attach a scene startup or object component script, copy panoramas into the project before Play, and enable the environment. See [Sky & atmosphere](https://rustic-game-engine.pages.dev/markdown/guides/scene-environment.md) for complete setup and all 13 fields.

## Parameters

This call has no arguments.

## Return and timing

Live settings as a fresh object. Partial updates validate and commit atomically and return the resulting settings; C reads return RusticValue and C setters return void.

## Execution behavior

Core write timing differs between immediate Lua host calls, deferred JavaScript/Web commands and external SDK query flushes. Scheduled actions advance with the scene clock; synchronous queries evaluate at the call. Follow [execution rules](https://rustic-game-engine.pages.dev/markdown/guides/scripting.md#when-mutations-take-effect) and the return/timing notes for this category.

## Language examples

Use these snippets inside Start/on_start after generating the Programming Workspace and attaching the script. Python imports rustic, Game and instance from rustic; C++ includes rustic.hpp; C includes rustic.h; C# uses using static Rustic; Java runs inside a Rustic subclass; PHP declares global $rustic, $Game, $instance in its callback. HTML uses an inline script in a ui/ asset. See [Lifecycle callbacks](https://rustic-game-engine.pages.dev/markdown/callbacks.md) for complete registration examples. Public-property examples require a declared integer health property. Scene examples require the named objects to exist before Play.

### Lua 5.4

```lua
Game.scene.setEnvironment({enabled=true,sun_intensity=1})
Game.scene.setSkyTexture('assets/skies/day.hdr')
print(Game.scene.getEnvironment().sky_image)
```

### JavaScript

```javascript
Game.scene.setEnvironment({enabled:true,sun_intensity:1});
Game.scene.setSkyTexture('assets/skies/day.hdr');
print(Game.scene.getEnvironment().sky_image);
```

### Python

```python
from rustic import Game, rustic
Game.scene.setEnvironment({'enabled':True,'sun_intensity':1})
Game.scene.setSkyTexture('assets/skies/day.hdr')
rustic.log('info', Game.scene.getEnvironment()['sky_image'])
```

### C++

```cpp
Game.scene.setEnvironment({{"enabled",true},{"sun_intensity",1.0}});
Game.scene.setSkyTexture("assets/skies/day.hdr");
auto sky=Game.scene.getEnvironment().at("sky_image").string();
```

### C#

```csharp
Game.scene.setEnvironment(new {enabled=true,sun_intensity=1});
Game.scene.setSkyTexture("assets/skies/day.hdr");
var sky=Game.scene.getEnvironment().GetProperty("sky_image").GetString();
```

### Luau

```lua
Game.scene.setEnvironment({enabled=true,sun_intensity=1})
Game.scene.setSkyTexture('assets/skies/day.hdr')
print(Game.scene.getEnvironment().sky_image)
```

### C

```c
Game.scene.setEnvironment("enabled",(RusticValue){.type=RUSTIC_BOOL,.boolean=true});
Game.scene.setEnvironment("sun_intensity",(RusticValue){.type=RUSTIC_NUMBER,.number=1});
Game.scene.setSkyTexture("assets/skies/day.hdr");
RusticValue sky=Game.scene.getEnvironment("sky_image");
```

### Java

```java
Game.scene.setEnvironment(java.util.Map.of("enabled",true,"sun_intensity",1));
Game.scene.setSkyTexture("assets/skies/day.hdr");
var env=(java.util.Map<?,?>)Game.scene.getEnvironment();
```

### PHP

```php
global $Game;
$Game->scene->setEnvironment(["enabled"=>true,"sun_intensity"=>1]);
$Game->scene->setSkyTexture("assets/skies/day.hdr");
$sky=$Game->scene->getEnvironment()["sky_image"];
```

### HTML / inline JS

```javascript
Game.scene.setEnvironment({enabled:true,sun_intensity:1});
Game.scene.setSkyTexture('assets/skies/day.hdr');
print(Game.scene.getEnvironment().sky_image);
```

## Shared Scene environment constraints

- Unknown settings and invalid values raise errors without mutating the environment. Exposure is limited to [-20,20]; colors/intensities/distances must be finite and non-negative; sun direction must be finite and nonzero.
- setSkyTexture changes only the image; set enabled=true separately. The renderer checks the image on the next frame. The panorama does not generate image-based lighting or reflections.
- Changes affect the running scene and do not save to the editor or appear in Apply Runtime Changes. Restart Play to restore authored settings.
- Every gameplay language calls the engine-owned API. Rustic supplies SDKs and dispatches callbacks; scripts do not parse requests or serialize responses. See the language guide for complete setup and callback registration.

## Errors and debugging

Read the constraints above and the Console diagnostic. Invalid types, non-finite values, stale targets or unavailable native services can fail validation. A failed callback disables the behavior; a failed source reload keeps the last good instance. Exact error messages depend on the language adapter. See [Troubleshooting](https://rustic-game-engine.pages.dev/markdown/troubleshooting.md).

## Related APIs

- [Game.scene.setEnvironment()](https://rustic-game-engine.pages.dev/markdown/api/environment/set-environment.md)
- [Game.scene.setSkyTexture()](https://rustic-game-engine.pages.dev/markdown/api/environment/set-sky-texture.md)

[All environment APIs](https://rustic-game-engine.pages.dev/markdown/api/environment.md)
