Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Vice_Versa · Jun 29, 2015 at 12:45 AM · animationmaterialspink

Cursor is showing up as pink rectangle?

So Im trying to make a script to animate my cursor (not a mouse cursor) also, im not using Gui Components at all. basically i have 32 different materials that are basically acting as a sprite sheet for this cursor. and if the cursor is over something selectable, it will change the material of the cursor 32 times over the course of 2 seconds. I havent added the Time.deltaTime stuff yet because now every time i play my game, the cursor just shows up as a pink rectangle, which im assuming means it has no material attached to it whatsoever. heres my code

 using UnityEngine;
 using System.Collections;
 
 public class CursorAnimation : MonoBehaviour {
     
         public Texture2D txCursor;
     static Material c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17,
     c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31, c32;
 
     Material[] c_array = new Material[]{c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31, c32};
     void Start()
     {
         c0 = Resources.Load ("mat_reticle", typeof(Material)) as Material;
         c1 = Resources.Load ("mat_c1", typeof(Material)) as Material;
         c2 = Resources.Load ("mat_c2", typeof(Material)) as Material;
         c3 = Resources.Load ("mat_c3", typeof(Material)) as Material;
         c4 = Resources.Load ("mat_c4", typeof(Material)) as Material;
         c5 = Resources.Load ("mat_c5", typeof(Material)) as Material;
         c6 = Resources.Load ("mat_c6", typeof(Material)) as Material;
         c7 = Resources.Load ("mat_c7", typeof(Material)) as Material;
         c8 = Resources.Load ("mat_c8", typeof(Material)) as Material;
         c9 = Resources.Load ("mat_9", typeof(Material)) as Material;
         c10 = Resources.Load ("mat_c10", typeof(Material)) as Material;
         c11 = Resources.Load ("mat_c11", typeof(Material)) as Material;
         c12 = Resources.Load ("mat_c12", typeof(Material)) as Material;
         c13 = Resources.Load ("mat_c13", typeof(Material)) as Material;
         c14 = Resources.Load ("mat_c14", typeof(Material)) as Material;
         c15 = Resources.Load ("mat_c15", typeof(Material)) as Material;
         c16 = Resources.Load ("mat_c16", typeof(Material)) as Material;
         c17 = Resources.Load ("mat_c17", typeof(Material)) as Material;
         c18 = Resources.Load ("mat_c18", typeof(Material)) as Material;
         c19 = Resources.Load ("mat_c19", typeof(Material)) as Material;
         c20 = Resources.Load ("mat_c20", typeof(Material)) as Material;
         c21 = Resources.Load ("mat_c21", typeof(Material)) as Material;
         c22 = Resources.Load ("mat_c22", typeof(Material)) as Material;
         c23 = Resources.Load ("mat_c23", typeof(Material)) as Material;
         c24 = Resources.Load ("mat_c24", typeof(Material)) as Material;
         c25 = Resources.Load ("mat_c25", typeof(Material)) as Material;
         c26 = Resources.Load ("mat_c26", typeof(Material)) as Material;
         c27 = Resources.Load ("mat_c27", typeof(Material)) as Material;
         c28 = Resources.Load ("mat_c28", typeof(Material)) as Material;
         c29 = Resources.Load ("mat_c29", typeof(Material)) as Material;
         c30 = Resources.Load ("mat_c30", typeof(Material)) as Material;
         c31 = Resources.Load ("mat_c31", typeof(Material)) as Material;
         c32 = Resources.Load ("mat_c32", typeof(Material)) as Material;
 
 
     }
 
         public void animateCursor()
         {
         int spot = 0;
         for (int x = 0; x < c_array.Length; x++){
         GetComponent<Renderer> ().material = c_array [spot];
             spot ++;
         }
         if (spot >= c_array.Length)
             spot = 0;
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by GiyomuGames · Jun 29, 2015 at 04:41 AM

What you are doing seems very strange. If you are trying to have an animation on the cursor why don't you use an animation instead of changing the material like you do? You can create an animation on your cursor which will change the sprite 32 times during 2 seconds (using only 1 material on your sprite).

But to answer your question, if you cursor is a pink rectangle then there must be a problem with the shader of your materials.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vice_Versa · Jun 29, 2015 at 08:58 AM 0
Share

I know it is, but ive never used animations in unity before, i dodnt really think.about it while i was doing it

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can I make animations snap to a frame? 1 Answer

Why are materials on diffuse pink? 0 Answers

Animate a river in Unity 2 Answers

How can I animate the surface of a 3D object? 0 Answers

How to select an animation clip by index number? 7 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges