Sometimes I can't find Documentation

In CameraRaycaster.cs on line ~38 I see “hit.Value”, but I can’t find Value in the documentation. Monodevelop tells me what it does, but I can’t find the Value method if I look in the Unity RaycastHit documentation. Sometimes I can’t find members or methods in the documentation, and this is one of those cases. Where should I actually be looking to find RaycastHit.Value in the docs? Thank you.

Hey Tengu,

HasValue and Value is not an Unity property, this is c#.

You may know it as: value != null

Example:

int? leet = 1337;
    
if (leet != null) {
    print(leet);
}

The Output is then 1337. In other words value != null is actually the same as HasValue.

Info: Make sure, that you have a nullable value for this. Remember what Ben showed us with the ?
and the Raycast. If you want know more, you have to read the Documentation from Microsofts C#.

Quick Console Example I wrote:

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int? leet = 1337;

            if (leet != null)
            {
                Console.WriteLine(leet);
                Console.ReadLine();
            }
        }
    }
}

With HasValue and Value:

using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int? leet = 1337;

            if (leet.HasValue)
            {
                Console.WriteLine(leet.Value);
                Console.ReadLine();
            }
        }
    }
}

Cheers

Privacy & Terms