Example #1
0
 private static void GetRegistry()
 {
     if (!currentRegistry)
     {
         currentRegistry = FindObjectOfType <ColorRegistry>();
     }
 }
        public void Load(GameObject gameObject, string[] data)
        {
            var emitter = gameObject.GetComponent <LaserEmitter>();

            if (data[0] != "NONE")
            {
                emitter.color = ColorRegistry.GetColor(data[0]);
            }
        }
        public void SetColor()
        {
            var selection = _selectionHandler.Selected;

            if (selection)
            {
                var colored = selection.GetComponent <ColoredObject>();
                if (colored != null)
                {
                    colored.Color = ColorRegistry.GetColor(colorField.text);
                }
            }
        }
Example #4
0
        public override void Propagate(LaserSegment inputSegment, Collider collider)
        {
            var transformedNormal = transform.TransformDirection(normal);
            var colors            = ColorRegistry.SplitColor(inputSegment.Color);

            if (math.dot(inputSegment.Ray.direction, transformedNormal) >= 0)
            {
                colors = (colors.Item2, colors.Item1);
            }
            {
                var outputDirection = math.reflect(inputSegment.Ray.direction, transformedNormal);
                var outSegment      = new LaserSegment(
                    new Ray(inputSegment.End, outputDirection),
                    inputSegment.Depth + 1,
                    colors.Item1
                    )
                {
                    EmissionNormal = math.dot(outputDirection, transformedNormal) >= 0 ? transformedNormal : -transformedNormal
                };
                inputSegment.Add(outSegment);
                EmitSegment(outSegment);
            }
            {
                var outputDirection = inputSegment.Ray.direction;
                var outSegment      = new LaserSegment(
                    new Ray(inputSegment.End, outputDirection),
                    inputSegment.Depth + 1,
                    colors.Item2
                    )
                {
                    EmissionNormal = math.dot(outputDirection, transformedNormal) >= 0
                        ? transformedNormal
                        : -transformedNormal
                };
                inputSegment.Add(outSegment);
                EmitSegment(outSegment);
            }
        }