Unity/photon/pun1/位置同期/アバター風のソースを表示
←
Unity/photon/pun1/位置同期/アバター風
ナビゲーションに移動
検索に移動
あなたには「このページの編集」を行う権限がありません。理由は以下の通りです:
この操作は、次のグループに属する利用者のみが実行できます:
登録利用者
。
このページのソースの閲覧やコピーができます。
==アバター風にしてみる== #[[unity/photon/pun1/位置同期/シンプル]] [ショートカット] の手順の続き #Cubeの下にCanvasを追加 #CubeのCanvasの下にTextを追加 #Cubeの下のCanvasのRenderModeをWorldSpaceへ(これでCubeにText座標がくっつくようになる) #CubeにBoxColliderが追加されていることを確認 #ヒエラルキートップにCanvas/InputTextとCanvas/Buttonを追加 #CubeのObserverdOptionにCubeScriptとPhotonTransformViewを追加 #CubeをPrefubに追加 #以下スクリプトでPrefubのCubeを呼び出す *PhotonManager.cs GameObject cube = PhotonNetwork.Instantiate("Cube", Vector3.zero, Quaternion.Euler(Vector3.zero),0); cube.name = "Cube"+cube.GetComponent<PhotonView>().ownerId; *CubeScript.sc <pre> using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; public class CubeScript : Photon.MonoBehaviour { public string str = "guest1"; void Awake() { this.name = "Cube"+GetComponent<PhotonView> ().ownerId; if (GetComponent<PhotonView> ().isMine) { GetComponent<Renderer> ().material.color = Color.red; } GameObject obj = GameObject.Find ("/Canvas/Button"); if (GetComponent<PhotonView> ().isMine) { obj.GetComponent<Button> ().onClick.AddListener (OnClick); } SetCubeText (); } void OnMouseDrag() { Debug.Log ("ownerId=" + GetComponent<PhotonView> ().ownerId); Debug.Log ("isMine=" + GetComponent<PhotonView> ().isMine); if (GetComponent<PhotonView>().isMine) { GetComponent<Renderer> ().material.color = Color.red; Vector3 objectPointInScreen = Camera.main.WorldToScreenPoint (this.transform.position); Vector3 mousePointInScreen = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, objectPointInScreen.z); Vector3 mousePointInWorld = Camera.main.ScreenToWorldPoint (mousePointInScreen); mousePointInWorld.z = this.transform.position.z; this.transform.position = mousePointInWorld; } } void OnClick() { if (GetComponent<PhotonView> ().isMine) { GameObject objstr = GameObject.Find ("/Canvas/InputField/Text"); str = objstr.transform.GetComponent<Text> ().text; } SetCubeText (); } void SetCubeText() { Debug.Log("name="+this.name); GameObject objstr = GameObject.Find(this.name + "/Canvas/Text"); try { objstr.transform.GetComponent<Text> ().text = str; } catch (NullReferenceException ex) { } } void OnPhotonSerializeView( PhotonStream stream, PhotonMessageInfo info ) { if (stream.isWriting) { Debug.Log ("cube isWriting="+str); //データの送信 stream.SendNext(str); } else { Debug.Log ("cube isread="+str); //データの受信 this.str = (string)stream.ReceiveNext(); SetCubeText (); } } } </pre>
Unity/photon/pun1/位置同期/アバター風
に戻る。
ナビゲーション メニュー
個人用ツール
ログイン
名前空間
ページ
議論
日本語
表示
閲覧
ソースを閲覧
履歴表示
その他
検索
案内
プログラムメモ
php
flutter
java
android
kotlin
ios
unity
unrealengine
javascript
mysql
sqlite
postgresql
oracle
mroonga
mongodb
flash
electron
cocos2dx
titanium
cpp
ruby
perl
python
accessメモ
rss
html
monaca
cordova
golang
blender
セキュリティ
テストツール
サーバメモ
linux
dotnet
apacheメモ
htaccessメモ
subversion
git
仮想サーバ
ansible
sendgrid
xampp
cacti
mecab
faces
flashpolicyd
fcs
jenkins
運用
デザインメモ
css
ユーザビリティ
ux
サービスメモ
twitter
facebook
instagram
mixi
セカンドライフ
通信ログ横取り
google
ustream
aws
gcp
plesk
azure
vps
AI
その他サービス
便利系メモ
SEO
モバイル
抽象変数名
DDD
クライアント
firefox
chrome
pgp
windows
mac
jmetar
Thunderbird
excel
libreoffice
vpnclient
doxygen
VisualStudioCode
fastlane
metaquest
cmsメモ
mediawiki
pukiwiki
wordpress
その他
資格
IT用語
pvを稼ぐ方法
将棋プログラム
その他
ログイン
ページ内
メインページ
最近の更新
人気のページ
問い合わせ
ツール
リンク元
関連ページの更新状況
ページ情報