Skip to content

Instantly share code, notes, and snippets.

@Frooxius
Created June 5, 2018 07:22
Show Gist options
  • Save Frooxius/5144da924124ded6b67c69b1c3b32c3f to your computer and use it in GitHub Desktop.
Save Frooxius/5144da924124ded6b67c69b1c3b32c3f to your computer and use it in GitHub Desktop.
SunMover Tooltip
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BaseX;
namespace FrooxEngine
{
[Category("Tools/Tooltips")]
public class SunMover : ToolTip
{
public override bool IsTipPointing { get { return true; } }
Light target;
protected override void OnAttach()
{
base.OnAttach();
Slot.AttachComponent<SphereCollider>().Radius.Value = 0.02f;
var visual = Slot.AddSlot("Visual");
var material = visual.AttachComponent<PBS_Metallic>();
var cylinder = visual.AttachMesh<CylinderMesh>(material);
material.AlbedoColor.Value = color.Black;
material.Metallic.Value = 0.1f;
material.Smoothness.Value = 0.9f;
material.EmissiveColor.Value = color.White * 0.9f;
visual.LocalRotation = floatQ.Euler(90, 0, 0);
visual.LocalPosition += float3.Forward * 0.55f;
visual.LocalScale = new float3(0.02f, 1f, 0.02f);
}
public override void OnPrimaryPress()
{
target = World.RootSlot.GetComponentInChildren<Light>(
l => l.LightType.Value == LightType.Directional);
}
public override void OnPrimaryHold()
{
if (target != null)
{
target.Slot.Forward = -Slot.Forward;
target.Intensity.Value = MathX.Clamp01(MathX.Dot(Slot.Forward, float3.Up) * 10f);
target.Enabled = MathX.Dot(Slot.Forward, float3.Up) > 0f;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment