Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 JokerJosh0001 · May 16 at 09:51 AM · texturebuttonphotonnetworkplayer

Button texture changing with photon,changing material with a button using photon

at the moment i have a script that changes your players material when you press a button to a color but it can only change it to a solid color but i want to to make it change it to a texture, the only thing that ive got to work is it to change a objects texture but i want it to change the players texture, the reason why the other one wont work is because it changes a objects color that is in the hierachy but when you go into playmode, thats when the player gets spawned because thats how photon works.

heres the script:

using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using UnityEngine.XR;

public class FeatherCollider : MonoBehaviour {

 private float hapticWaitSeconds = 0.05f;
 private void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent<HandColliders>())
     {
         StartVibration(other.GetComponent<HandColliders>().isLeftHand, 0.7f, 0.15f);
         buttonEnter(other.GetComponent<HandColliders>().isLeftHand);
     }
 }

 public virtual void buttonEnter (bool isLeftHand)
 {
     
         
     if (Material)
     {
     
     }
         
     else if (Color)
     {
         photonView.RPC("ChangePlayerMaterial", RpcTarget.All, new Vector3(this.colorValues.r, 
         this.colorValues.g, this.colorValues.b));
     }
 }
 public virtual void buttonExit()
 {

 }

 private NetworkPlayerSpawner networkPlayerSpawner;
 private PhotonView photonView;

 public Color colorValues;
 public Material materialValues;
 public bool Material;
 public bool Color;

 private void Start()
 {
     networkPlayerSpawner = 
     GameObject.Find("/NetworkManager").GetComponent<NetworkPlayerSpawner>();
 }

 private void Update()
 {
     if (PhotonNetwork.InRoom)
         if (networkPlayerSpawner.isPlayerSpwaned)
         {
             // networkSManager.spawnedPlayerPrefab.GetComponent<PhotonView>();
             if (photonView == null)
             {
                 photonView = 
                 networkPlayerSpawner.spawnedPlayerPrefab.GetComponent<PhotonView>();
             }
         }
 }


 public void StartVibration(bool forLeftController, float amplitude, float duration)
 {
     base.StartCoroutine(this.HapticPulses(forLeftController, amplitude, duration));
 }

 // Token: 0x06000315 RID: 789 RVA: 0x00016512 File Offset: 0x00014712
 private IEnumerator HapticPulses(bool forLeftController, float amplitude, float duration)
 {
     float startTime = Time.time;
     uint channel = 0U;
     InputDevice device;
     if (forLeftController)
     {
         device = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
     }
     else
     {
         device = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
     }
     while (Time.time < startTime + duration)
     {
         device.SendHapticImpulse(channel, amplitude, this.hapticWaitSeconds);
         yield return new WaitForSeconds(this.hapticWaitSeconds * 0.9f);
     }
     yield break;
 }

},

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

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

Texture change using a button with photon 0 Answers

How to create GUI BUTTON from this 1 Answer

Unity Photon WASD working but Virtual Joystick won't work after another player has joined the network...? How can i sync joystick. 2 Answers

MRTK Figma Bridge for Unity 0 Answers

Textures not Appearing When Loading from Different Scene 0 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