public void GenerateDecal(Texture2D hitTexture, GameObject affectedObj)
    {
        transform.Rotate(new Vector3(0, 0, Random.Range(-180.0f, 180.0f)));

        //<<91-04-14>>
        transform.localScale *= Random.Range(0.7f, 1.5f);
        //<<\91-04-14>>

        Decal.dCount++;
        Decal decal = gameObject.GetComponent <Decal>();

        decal.affectedObjects    = new GameObject[1];
        decal.affectedObjects[0] = affectedObj;
        decal.decalMode          = DecalMode.MESH_COLLIDER;
        decal.pushDistance       = 0.08f + DecalManager.Add(gameObject);

        //decal.pushDistance = 0.019f;

        Material mat = new Material(decal.decalMaterial);

        mat.mainTexture     = hitTexture;
        decal.decalMaterial = mat;
        decal.CalculateDecal();
        decal.transform.parent = affectedObj.transform;
    }
Exemple #2
0
    //Used to process DecalDecorator changes.
    private void OnSceneGUI()
    {
        //Selected instance.
        Decal decal = (Decal)target;

        //Will only calculate changes and process the new Decal
        //on Repaint and MouseDrag events.
        //MouseDrag will allow us to handle changes made to scene gizmos, while
        //Repaint will allow us to handle changes made to the Inspector.

        //If the user want the objects to be updated, let's do it.
        bool hasChanged = decal.HasChanged();

        if (!hasChanged && ((Event.current.type != EventType.MouseDrag && Event.current.type != EventType.Repaint) || Event.current.modifiers != 0))
        {
            return;
        }

        //On the editor, we'll use only MeshFilter.
        decal.decalMode = DecalMode.MESH_FILTER;

        if (hasChanged)
        {
            decal.ClearDecals();

            if (decal.checkAutomatically)
            {
                GetAffectedObjects(decal);
            }

            decal.CalculateDecal();

            GenerateUV(decal);
        }
    }
Exemple #3
0
    public void GenerateDecal(Texture2D mark, GameObject mesh, GameObject parent)
    {
        //IL_005e: Unknown result type (might be due to invalid IL or missing references)
        base.transform.Rotate(new Vector3(0f, 0f, Random.Range(-180f, 180f)));
        lifeTime = 0f;
        Decal.dCount++;
        Decal component = GetComponent <Decal>();

        component.affectedObjects    = new GameObject[1];
        component.affectedObjects[0] = mesh;
        component.decalMode          = 0;
        component.pushDistance       = 0.009f;
        Material material = new Material(component.decalMaterial);

        material.mainTexture    = mark;
        component.decalMaterial = material;
        component.CalculateDecal();
        ((Component)component).transform.parent = parent.transform;
    }