예제 #1
0
    private void SetToolEffectName(string name)
    {
        Debug.Assert(name != null);

        if (currentToolEffectName != name)
        {
            // Need to change the instance.
            DestroyToolEffectReplicant();
            currentToolEffectName = name;

            Util.Log($"new tool effect name: {name}");

            foreach (var prefab in toolEffectPrefabs)
            {
                if (currentToolEffectName.Contains(prefab.name))
                {
                    GameObject inst = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity);
                    toolEffectReplicant = inst.GetComponent <NetworkableToolEffect>();

                    // YOLO. Assume it's an on-actor effect.
                    if (toolEffectReplicant == null)
                    {
                        toolEffectReplicant = new OnActorToolEffect(inst);
                    }

                    toolEffectReplicant.SetSpatialAudio(true);
                    toolEffectReplicant.SetRayOriginTransform(toolEmissionAnchor);
                    toolEffectReplicant.SetTint(currentTint);
                    break;
                }
            }

            // Note that it is OK if at this point, currentToolEffectInstance is null. That just means we don't support networking that effect.
        }
    }
예제 #2
0
    public void OnTintChanged()
    {
        foreach (MeshRenderer _renderer in renderersForTint)
        {
            _renderer.material.SetColor("_MainTint", currentTint);
        }
        avatarMaterialControl.SetTint(currentTint);

        toolEffectReplicant?.SetTint(currentTint);
        createPreviewInst?.SetTint(currentTint);
    }