当前位置: 首页>>代码示例>>C#>>正文


C# Material.SetAll方法代码示例

本文整理汇总了C#中Material.SetAll方法的典型用法代码示例。如果您正苦于以下问题:C# Material.SetAll方法的具体用法?C# Material.SetAll怎么用?C# Material.SetAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Material的用法示例。


在下文中一共展示了Material.SetAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Join

    /// <summary>
    /// The ship is built by having all of its parts fly together.
    /// </summary>
    /// <param name="buildInfo">Ship instructions.</param>
    /// <param name="buildSize">Size of the grid.</param>
    /// <param name="transform">Ship transforms.</param>
    /// <param name="maxTime">How long the building process can take.</param>
    /// <param name="finishedAction">Method to call when completed.</param>
    public static IEnumerator Join(BuildInfo buildInfo, int buildSize, Transform transform, float maxTime, Action<BuildFinishedArgs> finishedAction = null)
    {
        var pieces = new List<BuildCUBE>();

        const float minDist = 100f;
        const float maxDist = 250f;
        Vector3 halfGrid = Vector3.one * (buildSize / 2f - 1f);
        Vector3 pivotOffset = -Vector3.one / 2f;
        float speed = maxDist / maxTime;

        foreach (var piece in buildInfo.partList)
        {
            CUBE cube = GameResources.CreateCUBE(piece.Key);
            cube.transform.parent = transform;
            Material[] materials = new Material[cube.renderer.materials.Length];
            materials.SetAll(material);
            cube.renderer.materials = materials;

            cube.transform.localPosition = piece.Value.position.normalized * Random.Range(minDist, maxDist);
            cube.transform.localPosition = Quaternion.Euler(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360)) * cube.transform.localPosition;
            cube.transform.localEulerAngles = piece.Value.rotation;

            if (piece.Value.weaponMap != -1)
            {
                ((Weapon)cube.GetComponent(typeof(Weapon))).index = piece.Value.weaponMap;
            }

            if (piece.Value.augmentationMap != -1)
            {
                ((Augmentation)cube.GetComponent(typeof(Augmentation))).index = piece.Value.augmentationMap;
            }

            ((ColorVertices)cube.GetComponent(typeof(ColorVertices))).Bake(piece.Value.colors);

            pieces.Add(new BuildCUBE(cube.transform, piece.Value.position - halfGrid + Utility.RotateVector(pivotOffset, Quaternion.Euler(piece.Value.rotation)), speed));
        }

        float time = maxTime;
        while (time > 0f)
        {
            foreach (BuildCUBE piece in pieces)
            {
                piece.Update(Time.deltaTime);
            }
            time -= Time.deltaTime;
            yield return null;
        }

        if (finishedAction != null)
        {
            finishedAction(new BuildFinishedArgs(transform.gameObject, buildInfo.stats, buildInfo.trimColor));
        }
    }
开发者ID:syeager,项目名称:Space-CUBEs,代码行数:61,代码来源:ShowBuild.cs


注:本文中的Material.SetAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。