Question by 
               RonnieThePotatoDEV · Apr 01, 2017 at 07:47 PM · 
                c#spritesprite renderer  
              
 
              How do I change a game object's sprite in C#
I have seen plenty of similar questions, but none of them work for me. I keep getting this error:
"Error CS0411: The type arguments for method `UnityEditor.AssetDatabase.LoadAssetAtPath(string)' cannot be inferred from the usage. Try specifying the type arguments explicitly (CS0411) (Assembly-CSharp)"
Heres the code I use:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
 
 public class BallControl : MonoBehaviour {
 
     public float BallStartSpeed = 2f;
     public GameObject Score_1;
     public SpriteRenderer Score1Sprite;
     public Sprite Pong_N1;
 
     private int Score1 = 0;
     private int Score2 = 0;
     private Rigidbody2D rbBall;
     private Vector2 BallDirection;
 
     void Start()
     {
         Score_1 = GameObject.Find ("Score_1");
         Score1Sprite = Score_1.GetComponent<SpriteRenderer>();
         rbBall = GetComponent<Rigidbody2D> ();
         BallStart();
     }
     void Update()
     {
         if (Score1 == 1) {
             Score1Sprite.sprite = (Sprite)AssetDatabase.LoadAssetAtPath("Assets/Sprites/Pong_N1"); //This is where i get the error
         }
     }
 }
               Comment
              
 
               
              Answer by gulnurzehra · Apr 01, 2017 at 11:28 PM
What do you mean by load?
$$anonymous$$ake an if statement that sets the previous sprite false and the new sprite true:
gameObject.GetComponent().enabled = true;
Your answer
 
 
             Follow this Question
Related Questions
Destroying 2D terrain at runtime 0 Answers
Change sprite size programmatically 0 Answers
How to change image sprite with text multiple times with button? 1 Answer
Sprite didn't change more than once 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                