Xenko Toolkit is a .NET Standard library for use with the Xenko Game Engine. It's goal is to add extra extensions and utilites to make things a bit easier.
Coming Soon™
Install-Package XenkoToolkit -Prerelease
This table indicates which version of Xenko each version of the toolkit was compiled against.
Branch | NuGet | Xenko |
---|---|---|
master | 0.1.0.0-alpha | 2.1.1.1 |
Find Component
s more easily:
//Find component in self or children
var model = this.Entity.GetComponentInChildren<ModelComponent>();
//Find all components in self and children
var models = this.Entity.GetComponentsInChildren<ModelComponent>();
Pick and aim at an Entity
:
if (Input.IsMouseButtonPressed(SiliconStudio.Xenko.Input.MouseButton.Left))
{
var ray = MainCamera.ScreenToWorldRaySegment(Input.MousePosition);
var hitResult = this.GetSimulation().Raycast(ray);
if (hitResult.Succeeded)
{
target = hitResult.Collider.Entity;
}
}
if(target != null)
{
MainCamera.Entity.Transform.LookAt(target.Transform, Game.GetDeltaTime() * 3.0f);
}
Execute a method when an event occurs:
public class ReceiverScript : StartupScript
{
private List<MicroThread> tasks;
public override void Start()
{
//Keep a list of tasks to stop on cancel
tasks = new List<MicroThread>()
{
//Directly using EventKey so you don't have to declare EventReciever:
Script.AddOnEventAction(SenderScript.SomeEvent, HandleSomeEvent),
};
}
private void HandleSomeEvent(Vector2 position)
{
//Do something cool!!
}
public override void Cancel()
{
base.Cancel();
//Stop handling event
tasks.CancelAll();
}
}
Execute methods at a delayed time:
Script.AddAction(DelayedAction, TimeSpan.FromSeconds(2));
//async method
Script.AddTask(DelayedTask, TimeSpan.FromSeconds(2));
Repeat method execute at a given time span:
Script.AddAction(RepeatedAction, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2));
//async method
Script.AddTask(RepeatedTask, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2));
Animate a property using an easing function:
//Instantiate prefab at a given postion
var sphere = SpherePrefab.InstantiateSingle(FirstPosition);
Entity.Scene.Entities.Add(sphere);
Script.AddOverTimeAction((progress) =>
{
sphere.Transform.Position = MathUtilEx.Interpolate(startPosition, endPosition, progress,EasingFunction.ElasticEaseOut);
}, TimeSpan.FromSeconds(2));
- Xenko (and it's prerequisites for Windows).
...
...
This project is licensed under the APACHE 2.0 License - see the LICENSE.txt file for details