コード例 #1
0
ファイル: VgoRightValidator.cs プロジェクト: bmjoy/VGO
        /// <summary>
        /// Perform verification.
        /// </summary>
        /// <param name="vgoRight"></param>
        /// <param name="errorMessage"></param>
        /// <returns>Returns true if validation is successful, false otherwise.</returns>
        public static bool Validate(VgoRight vgoRight, out string errorMessage)
        {
            glTF_VGO_Right right = vgoRight.Right;

            var errorMessages = new[]
            {
                ValidateField("Title", right.title),
                ValidateField("Author", right.author),
                ValidateField("Organization", right.organization),
                ValidateField("CreatedDate", right.createdDate),
                ValidateField("UpdatedDate", right.updatedDate),
                ValidateField("Version", right.version),
                ValidateField("DistributionUrl", right.distributionUrl),
                ValidateField("LicenseUrl", right.licenseUrl),
            };

            if (errorMessages.Any(m => !string.IsNullOrEmpty(m)))
            {
                errorMessage = string.Join(Environment.NewLine, errorMessages.Where(m => !string.IsNullOrEmpty(m)).ToArray());

                return(false);
            }
            else
            {
                errorMessage = string.Empty;

                return(true);
            }
        }
コード例 #2
0
        /// <summary>
        /// Adds a VgoRight component to the game object.
        /// </summary>
        /// <typeparam name="T">The type of the component to add.</typeparam>
        /// <param name="go"></param>
        /// <param name="gltfRight"></param>
        /// <returns>Returns VgoRight component.</returns>
        public static VgoRight AddComponent <T>(this GameObject go, glTF_VGO_Right gltfRight)
            where T : VgoRight
        {
            VgoRight vgoRight = go.GetComponent <VgoRight>();

            if (vgoRight == null)
            {
                vgoRight = go.AddComponent <VgoRight>();
            }

            if (gltfRight == null)
            {
                vgoRight.Right = null;
            }
            else
            {
                vgoRight.Right = new glTF_VGO_Right(gltfRight);
            }

            return(vgoRight);
        }