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 /
  • Help Room /
avatar image
0
Question by EpicScorp · Apr 13, 2021 at 09:55 PM · materialandroid buildrendererchange material

Renderer.Material doesn't work on android Build

Hi everyone, my trouble is this:

i made a Maze game with a shop at main menu, there you can buy different skins for the table and the ball. i've created 6 different ones and a default one (7 in total) for scenario and the same for balls. Each one has a button to equip the skin. That button change the material on floor and walls or ball.

alt text

On unity editor all works fine, you can switch skins without any trouble, but when i build it and tested with my phone this doesn't work, i press all equip buttons but any change.

I leave my script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class ChangeTexture : MonoBehaviour
 {
     public GameObject player;
     public GameObject wall;
     public Material material_1;
     public Material material_2;
     public Material material_3;
     public Material material_4;
     public Material material_5;
     public Material material_6;
     public Material material_7;
 
     int materialCase = 0;
 
     public void material1()
     {
         materialCase = 1;
         CambiarMaterial();
     }
 
     public void material2()
     {
         materialCase = 2;
         CambiarMaterial();
     }
 
     public void material3()
     {
         materialCase = 3;
         CambiarMaterial();
     }
 
     public void material4()
     {
         materialCase = 4;
         CambiarMaterial();
     }
 
     public void material5()
     {
         materialCase = 5;
         CambiarMaterial();
     }
 
     public void material6()
     {
         materialCase = 6;
         CambiarMaterial();
     }
 
     public void material7()
     {
         materialCase = 7;
         CambiarMaterial();
     }
 
     public void CambiarMaterial()
     {
         Renderer rend = player.GetComponent<Renderer>();
         Renderer rendd = wall.GetComponent<Renderer>();
         switch (materialCase)
         {
             case 7:
                 rend.material = material_7;
                 rendd.material = material_7;
                 break;
             case 6:
                 rend.material = material_6;
                 rendd.material = material_6;
                 break;
             case 5:
                 rend.material = material_5;
                 rendd.material = material_5;
                 break;
             case 4:
                 rend.material = material_4;
                 rendd.material = material_4;
                 break;
             case 3:
                 rend.material = material_3;
                 rendd.material = material_3;
                 break;
             case 2:
                 rend.material = material_2;
                 rendd.material = material_2;
                 break;
             case 1:
                 rend.material = material_1;
                 rendd.material = material_1;
                 break;
             default:
                 break;
         }
     }
 }


Any idea that why this doesn't work? This is my first game and i'm still learning :(

example.jpg (243.8 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

175 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 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 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 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 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 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 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 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

Shader not working properly in a build 0 Answers

Anyway to detect for missing material from Renderer component? 1 Answer

Objects disappears when more than 2 Objects share the same material [android] 0 Answers

How to Disable or hide a material in Unity. 0 Answers

How to know if renderer.material.GetFloat() exist 1 Answer


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