Search Unity

Change emission brigthness in standard shader with script - standalone player

Discussion in 'Scripting' started by potter3366, May 10, 2016.

  1. potter3366

    potter3366

    Joined:
    Oct 15, 2009
    Posts:
    65
    I can change emission brigthness in play mode, but not in windows standalone player:


    Code (CSharp):
    1.   using UnityEngine;
    2.   using System.Collections;
    3.  
    4.   public class Load : MonoBehaviour
    5.   {
    6.  
    7.      private int brojac;
    8.      private GameObject clone;
    9.      private bool kontrola;
    10.      private Material mat;
    11.      private Renderer rend;
    12.      public GameObject[] tileObjects;
    13.  
    14.  
    15.      void Start ()
    16.      {
    17.        brojac = 0;
    18.        kontrola = true;
    19.      }
    20.  
    21.  
    22.      void Update ()
    23.      {
    24.  
    25.        if (Input.GetMouseButtonDown (0) && kontrola) {
    26.          load_model ();
    27.        }
    28.      
    29.        if (clone != null && !kontrola) {
    30.      
    31.          if (Input.GetMouseButtonDown (1)) {
    32.            Destroy ();
    33.          }
    34.  
    35.          if (Input.GetKey ("k")) {
    36.            rend.material.SetColor ("_EmissionColor", Color.red * 1.5f);
    37.            //DynamicGI.SetEmissive (rend, Color.red);
    38.            DynamicGI.UpdateMaterials (rend);
    39.          }
    40.          if (Input.GetKey ("l")) {
    41.            rend.material.SetColor ("_EmissionColor", Color.black);
    42.            //DynamicGI.SetEmissive (rend, Color.black);
    43.            DynamicGI.UpdateMaterials (rend);
    44.          }
    45.        
    46.  
    47.        }
    48.  
    49.      }
    50.  
    51.  
    52.      void load_model ()
    53.      {
    54.  
    55.        clone = Instantiate (tileObjects [brojac], new Vector3 (0, 0, 0), Quaternion.identity) as GameObject;
    56.        clone.name = "Lamp";
    57.        rend = clone.GetComponent<Renderer> ();
    58.        rend.material.EnableKeyword ("_EMISSION");
    59.        kontrola = false;
    60.  
    61.      }
    62.  
    63.  
    64.      void Destroy ()
    65.      {
    66.        Destroy (clone, 0.5f);
    67.        brojac++;
    68.        if (brojac == 15)
    69.          brojac = 0;
    70.        kontrola = true;
    71.      }
    72.  
    73.   }
    74.  
     
  2. potter3366

    potter3366

    Joined:
    Oct 15, 2009
    Posts:
    65
    SOLUTION

    Edit - Project Settings - Graphics - Include Standard Shaders
     
    LeftyRighty likes this.
  3. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,838
    Where do you see this option? Is this something new? I am using Unity 5.2.3. There is no option for this, but I can set the emission color anyways for the player.
    graphics.jpg

    j
     
  4. potter3366

    potter3366

    Joined:
    Oct 15, 2009
    Posts:
    65
    shaders.jpg


    All my 15 objects are prefabs.
    Please post your solution...
     
    Last edited: May 10, 2016
  5. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,838
    I have a material in the Resources folder using the standard shader. So then I think, for my situation, the Standard shader will be automatically be included because it is used for something in the Resources folder. That might explain why I don't need to add it the list.