Пример #1
0
    public static bool ValidateMinMaxArray(MinMaxValues[] array, MinMaxValues validMinRange, MinMaxValues validMaxRange)
    {
        bool valid = ValidateMixMaxArray_MinVsMax(array);

        for (int i = 0; i < array.Length; i++)
        {
            if (array[i].min < validMinRange.min)
            {
                Debug.LogError("Array of MinMaxValues: [" + i + "], min is invalid at " + array[i].min + ", must be at least " + validMinRange.min);
                valid = false;
            }

            if (array[i].min > validMinRange.max)
            {
                Debug.LogError("Array of MinMaxValues: [" + i + "], min is invalid at " + array[i].min + ", must be no more than " + validMinRange.max);
                valid = false;
            }

            if (array[i].max < validMaxRange.min)
            {
                Debug.LogError("Array of MinMaxValues: [" + i + "], max is invalid at " + array[i].max + ", must be at least " + validMaxRange.min);
                valid = false;
            }

            if (array[i].max > validMaxRange.max)
            {
                Debug.LogError("Array of MinMaxValues: [" + i + "], max is invalid at " + array[i].max + ", must be no more than " + validMaxRange.max);
                valid = false;
            }
        }

        return(valid);
    }
Пример #2
0
    void Start()
    {
        if (audioSource == null)
        {
            audioSource = GetComponent <AudioSource>();
        }

        if (audioSource == null)
        {
            Debug.LogError("No AudioSource assigned or detected.");
        }

        if (clips.Length == 0)
        {
            Debug.LogError("No AudioClips assigned.");
        }

        if (
            (clips.Length != clips_randomWeights.Length) ||
            (clips.Length != clips_randPitchRanges.Length) ||
            (clips_randomWeights.Length != clips_randPitchRanges.Length)
            )
        {
            Debug.LogError("Arrays whose names start with the word 'clips' are parallel arrays and must have the name number of elements.");
        }


        CodeTools.ValidateWeightedRandomArray(clips_randomWeights, clips.Length);

        MinMaxValues minmax = new MinMaxValues(-3f, 3f);

        CodeTools.ValidateMinMaxArray(clips_randPitchRanges, minmax, minmax);

        lastTriggerTime = dontTriggerUntil;  // this is how dontTriggerUntil is implemented
    }
Пример #3
0
    void Start()
    {
        if (targetTransform == null)
        {
            Debug.LogError("targetTransform not assigned.");
        }

        if (targetSlot == null)
        {
            targetSlot = targetTransform.gameObject.GetComponent <Slot>();
        }

        if (targetSlot == null)
        {
            Debug.LogError("targetSlot not assigned, and no Slot component found on targetTransform object.");
        }

        if (positionTolerance.Length != 3)
        {
            Debug.LogError("positionTolerance must be an array of size 3, where element 0 defines X tolerance, element 1 defines Y tolerance, and element 2 defines Z tolerance.");
        }

        MinMaxValues notMoreThanZero = new MinMaxValues(-999f, 0f);
        MinMaxValues notLessThanZero = new MinMaxValues(0f, 999f);

        CodeTools.ValidateMinMaxArray(positionTolerance, notMoreThanZero, notLessThanZero);

        if (rotationTolerance < 0)
        {
            Debug.LogError("rotationTolerance must be great than 0.");
        }

        if (checkPeriod < 0)
        {
            Debug.LogError("checkPeriod must be greater than 0 and should be much less than 1 (try 0.03 maybe).");
        }

        if (startSlotted)
        {
            // TODO - this code is pretty much duplicate copy/pasted from below
            SnapToTargetPosition();
            if (targetSlot != null)
            {
                targetSlot.ObjectHasSlotted(this);
            }
            if (becomeNonphysicalWhenSlotted)
            {
                BecomePhysical(false);   // do this last, because by default at present VRInteractable will make the object physical again when dropped when CommunicateSnapToOtherScripts() is called
            }
        }
    }
Пример #4
0
 public void SetValues(MinMaxValues values)
 {
     SetValues(values.minValue, values.maxValue, values.minLimit, values.maxLimit);
 }