我在执行 [Command] 时收到有关权限的警告消息,但我找不到此警告的来源。当我拖动一个对象时,我得到了这个。
a) 我不明白为什么以及在哪里收到警告信息?
b)我不明白为什么它不是localplayer并且第二次拥有权限?
c) 我不明白为什么当 localplayer 和 hasauthority 为假时 yt 为“0”?
如果有人可以向我解释这一点,我将不胜感激?给我解释一下?
我使用 EasyTouch 进行触摸。
//======================================================================//
// //
// On_DragStart //
// //
//======================================================================//
public void On_DragStart (Gesture gesture) {
print ("On_DragStart");
if (!isLocalPlayer)
return;
if (!hasAuthority)
return;
if (selected_GO == null)
return;
// Cmd_SetAuthority(selected_GO.GetComponent<NetworkIdentity>().netId, gameObject.GetComponent<NetworkIdentity>());
}
private bool firstLoop = true;
private int yt = 0;
//======================================================================//
// //
// On_Drag //
// //
//======================================================================//
public void On_Drag (Gesture gesture) {
// print ("On_Drag");
print ("a) " + yt + " isLocalPlayer: " + isLocalPlayer);
if (!isLocalPlayer)
return;
print ("b) " + yt + " hasAuthority: " + hasAuthority);
if (!hasAuthority)
return;
print ("c) " + yt + " selected_GO: " + selected_GO.name);
if (selected_GO == null)
return;
print ("d) " + yt);
if (firstLoop) {
print ("e) " + yt);
if (selected_GO.GetComponent<NetworkIdentity> ().hasAuthority == false) {
print ("f) " + yt);
var networkIdentity = selected_GO.GetComponent<NetworkIdentity>();
var otherOwner = networkIdentity.clientAuthorityOwner;
networkIdentity.RemoveClientAuthority(otherOwner);
}
print ("g) " + yt);
}
// Only allow drag if player own object
if (selected_GO.GetComponent<NetworkIdentity> ().hasAuthority == true) {
// Check if there have been a linecast, if so use that Game Object for drag
print ("h) " + yt);
if (selected_GO != null) {
print ("i) " + yt);
selected_GO.transform.position = Camera.main.ScreenToWorldPoint (new Vector3 (gesture.position.x, gesture.position.y, 1f));
} else if (gesture.pickedObject != null) {
print ("j) " + yt);
gesture.pickedObject.transform.position = Camera.main.ScreenToWorldPoint (new Vector3 (gesture.position.x, gesture.position.y, 1f));
}
}
print ("k) " + yt);
yt++;
}
//======================================================================//
// //
// On_DragEnd //
// //
//======================================================================//
public void On_DragEnd (Gesture gesture) {
print ("On_DragEnd");
if (!isLocalPlayer && !hasAuthority)
return;
if (selected_GO == null)
return;
if (containerMode) {
DisableParentChildRelationship (_syncEngine.cardNames_SList);
// Color all cards in container white to show that this is not a container anylonger
foreach (string aSTR in _syncEngine.cardNames_SList) {
temp_GO = GameObject.FindWithTag (aSTR);
Cmd_Paint (temp_GO, Color.white);
}
} else {
if (selected_GO.GetComponent<NetworkIdentity> ().hasAuthority == true) {
Cmd_SetAuthority(selected_GO.GetComponent<NetworkIdentity>().netId, gameObject.GetComponent<NetworkIdentity>());
}
}
}
这是我在拖动时从这段代码中得到的打印:
On_DragStart
On_DragStart
a) 0 isLocalPlayer: True
b) 0 hasAuthority: True
c) 0 selected_GO: _H4_Gun
d) 0
e) 0
f) 0
g) 0
h) 0
i) 0
k) 0
a) 0 isLocalPlayer: False
Command for object without authority [netId=9]
Command for object without authority [netId=9]
Command for object without authority [netId=9]
Command for object without authority [netId=9]
a) 1 isLocalPlayer: True
b) 1 hasAuthority: True
c) 1 selected_GO: _H4_Gun
d) 1
h) 1
i) 1
k) 1
a) 0 isLocalPlayer: False
Command for object without authority [netId=9]
Command for object without authority [netId=9]
a) 2 isLocalPlayer: True
b) 2 hasAuthority: True
c) 2 selected_GO: _H4_Gun
d) 2
h) 2
i) 2
k) 2
a) 0 isLocalPlayer: False
a) 3 isLocalPlayer: True
b) 3 hasAuthority: True
c) 3 selected_GO: _H4_Gun
d) 3
h) 3
i) 3
k) 3
…etc.