Ejemplo n.º 1
0
        /// <summary>
        /// tries to convert converts any NodePort's input to a float[]
        /// </summary>
        /// <param name="np">NodePort to fetch data from</param>
        /// <param name="targetArray">result of casting input to float[]</param>
        /// <returns></returns>
        protected bool ProcessNodeInput(NodePort np, out float[] targetArray)
        {
            if (np.TryGetInputValue <float[]>(out targetArray))
            {
                return(true);
            }


            float inFloat;

            if (np.TryGetInputValue <float>(out inFloat))
            {
                if (targetArray == null || targetArray.Length != noiseGraph.TotalCells)
                {
                    targetArray = new float[noiseGraph.TotalCells];
                }

                for (int i = 0; i < targetArray.Length; i++)
                {
                    targetArray[i] = inFloat;
                }
                return(true);
            }
            else
            {
                Debug.Log("Invalid Input: " + np.fieldName);
            }

            targetArray = null;
            return(false);
        }