Ejemplo n.º 1
0
    /// <summary>
    /// Make sure the given <see cref="NearDistance"/> and <see cref="FarDistance"/> define a valid
    /// distance range.
    /// </summary>
    /// <returns>
    /// True if <see cref="NearDistance"/> and <see cref="FarDistance"/> are both positive, and if
    /// <see cref="NearDistance"/> is greater than <see cref="FarDistance"/> (otherwise a specific
    /// error message will be shown).
    /// </returns>
    private bool VerifyRange()
    {
        // Make sure both given distances are positive.
        if (NearDistance <= 0f)
        {
            Debug.LogError(ExampleErrors.NotGreaterThanZero(this, NearDistance, "Near Distance"));
            return(false);
        }
        if (FarDistance <= 0f)
        {
            Debug.LogError(ExampleErrors.NotGreaterThanZero(this, FarDistance, "Far Distance"));
            return(false);
        }

        // Make sure the given far distance is greater than near distance.
        if (FarDistance <= NearDistance)
        {
            Debug.LogError(ExampleErrors
                           .NotGreaterThan(this, FarDistance, "Far Distance", NearDistance, "Near Distance"));
            return(false);
        }

        // If have reached this point then given near and far distances are valid, so return true.
        return(true);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Verify that all required parameters have been correctly defined, returning false if not.
    /// </summary>
    private bool VerifyParameters()
    {
        // Verify that an Emission Controller has been defined.
        if (EmissionController == null)
        {
            Debug.LogError(ExampleErrors.MissingParameter(this, EmissionController, "Emission Controller",
                                                          "to control the emission values of in-scene lights/windows"));
            return(false);
        }

        // Get required light on this gameObject and make sure it is a directional light.
        Light = GetComponent <Light>();
        if (Light.type != LightType.Directional)
        {
            Debug.LogWarningFormat("{0}.{1} found a {2}-light attached to {0}, when a Directional Light "
                                   + "was expected.\n Changing type from {2} to Directional.",
                                   name, GetType(), Light.type);
            Light.type = LightType.Directional;
        }

        // Verify given Fog Distances.
        if (FogStart < 0f)
        {
            Debug.LogError(ExampleErrors.NotGreaterThanZero(this, FogStart, "Fog Start distance",
                                                            ", as this represents the Linear Fog Start Distance for the scene"));
            return(false);
        }
        if (FogEnd < FogStart)
        {
            Debug.LogError(ExampleErrors.NotGreaterThan(this, FogEnd, "Fog End distance", FogStart,
                                                        "Fog Start distance"));
            return(false);
        }

        // Verify given Render Distance is positive.
        if (RenderDistance < 0f)
        {
            Debug.LogError(ExampleErrors.NotGreaterThanZero(this, RenderDistance, "Render Distance",
                                                            ", as this represents the Camera's far Clipping Plane"));
            return(false);
        }

        // If have reached this point then have verified that all required parts are present and
        // properly setup.
        return(true);
    }