Search Unity

  1. Full schedule for #UniteBerlin is now available! Featuring talks on our roadmap, hands-on labs and much more! Check it out!
    Dismiss Notice
  2. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  3. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Trying to reduce the yellow warnings in project

Discussion in 'Scripting' started by tawdry, May 16, 2018.

  1. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,012
    Hi
    So i have a couple hundred yellow warning from assets iv downloaded mostly particle systems so trying to cut down on them but can't figure out why this code gives the following warning


    Assets/Standard Assets/Effects/ImageEffects/FT_Infinity_lite/Scenes/Data/Scripts/SpawnProjectile.cs(50,15): warning CS0219: The variable `projectile' is assigned but its value is never used


    Error points to the last line how can i rewrite it to have the yellow error msg go bye bye.


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class SpawnProjectile : MonoBehaviour {
    7.  
    8.     public Camera mainCam;
    9.     public Transform spawn;
    10.     public GameObject[] effects;
    11.     private int count = 0;
    12.     public Text text;
    13.  
    14.     // Use this for initialization
    15.     void Start () {
    16.         text.text = effects [count].name;
    17.     }
    18.    
    19.     // Update is called once per frame
    20.     void Update () {
    21.         //Player Look at Mouse Position
    22.         Ray ray = mainCam.ScreenPointToRay(Input.mousePosition);
    23.         Plane ground = new Plane (Vector3.up, Vector3.zero);
    24.         float rayDistance;
    25.         if (ground.Raycast (ray, out rayDistance)) {
    26.             Vector3 point = ray.GetPoint (rayDistance);
    27.             Vector3 correctPoint = new Vector3 (point.x, transform.position.y, point.z);
    28.             transform.LookAt (correctPoint);
    29.         }
    30.         if (Input.GetKeyDown (KeyCode.RightArrow)) {
    31.             if (count >= effects.Length -1) {
    32.                 count = 0;
    33.             } else {
    34.                 count++;
    35.             }
    36.             text.text = effects [count].name;
    37.         }
    38.  
    39.         if (Input.GetKeyDown (KeyCode.LeftArrow)) {
    40.             if (count <= 0) {
    41.                 count = effects.Length -1;
    42.             } else {
    43.                 count--;
    44.             }
    45.             text.text = effects [count].name;
    46.         }      
    47.  
    48.         //Shoot
    49.         if(Input.GetMouseButtonDown(0)){
    50.             GameObject projectile = Instantiate (effects[count], spawn.position, spawn.rotation);
    51.         }
    52.     }
    Thx
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    1,411
  3. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,012
    Ah ok thx.