Here are the examples of the csharp api UnityEngine.Debug.LogError(object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
892 Examples
19
Source : Tonemapping.cs
with Apache License 2.0
from activey
with Apache License 2.0
from activey
[ImageEffectTransformsToLDR]
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (CheckResources() == false)
{
Graphics.Blit(source, destination);
return;
}
#if UNITY_EDITOR
validRenderTextureFormat = true;
if (source.format != RenderTextureFormat.ARGBHalf)
{
validRenderTextureFormat = false;
}
#endif
// clamp some values to not go out of a valid range
exposureAdjustment = exposureAdjustment < 0.001f ? 0.001f : exposureAdjustment;
// SimpleReinhard tonemappers (local, non adaptive)
if (type == TonemapperType.UserCurve)
{
float rangeScale = UpdateCurve();
tonemapMaterial.SetFloat("_RangeScale", rangeScale);
tonemapMaterial.SetTexture("_Curve", curveTex);
Graphics.Blit(source, destination, tonemapMaterial, 4);
return;
}
if (type == TonemapperType.SimpleReinhard)
{
tonemapMaterial.SetFloat("_ExposureAdjustment", exposureAdjustment);
Graphics.Blit(source, destination, tonemapMaterial, 6);
return;
}
if (type == TonemapperType.Hable)
{
tonemapMaterial.SetFloat("_ExposureAdjustment", exposureAdjustment);
Graphics.Blit(source, destination, tonemapMaterial, 5);
return;
}
if (type == TonemapperType.Photographic)
{
tonemapMaterial.SetFloat("_ExposureAdjustment", exposureAdjustment);
Graphics.Blit(source, destination, tonemapMaterial, 8);
return;
}
if (type == TonemapperType.OptimizedHejiDawson)
{
tonemapMaterial.SetFloat("_ExposureAdjustment", 0.5f*exposureAdjustment);
Graphics.Blit(source, destination, tonemapMaterial, 7);
return;
}
// still here?
// => adaptive tone mapping:
// builds an average log luminance, tonemaps according to
// middle grey and white values (user controlled)
// AdaptiveReinhardAutoWhite will calculate white value automagically
bool freshlyBrewedInternalRt = CreateInternalRenderTexture(); // this retrieves rtFormat, so should happen before rt allocations
RenderTexture rtSquared = RenderTexture.GetTemporary((int) adaptiveTextureSize, (int) adaptiveTextureSize, 0, rtFormat);
Graphics.Blit(source, rtSquared);
int downsample = (int) Mathf.Log(rtSquared.width*1.0f, 2);
int div = 2;
var rts = new RenderTexture[downsample];
for (int i = 0; i < downsample; i++)
{
rts[i] = RenderTexture.GetTemporary(rtSquared.width/div, rtSquared.width/div, 0, rtFormat);
div *= 2;
}
// downsample pyramid
var lumRt = rts[downsample - 1];
Graphics.Blit(rtSquared, rts[0], tonemapMaterial, 1);
if (type == TonemapperType.AdaptiveReinhardAutoWhite)
{
for (int i = 0; i < downsample - 1; i++)
{
Graphics.Blit(rts[i], rts[i + 1], tonemapMaterial, 9);
lumRt = rts[i + 1];
}
}
else if (type == TonemapperType.AdaptiveReinhard)
{
for (int i = 0; i < downsample - 1; i++)
{
Graphics.Blit(rts[i], rts[i + 1]);
lumRt = rts[i + 1];
}
}
// we have the needed values, let's apply adaptive tonemapping
adaptionSpeed = adaptionSpeed < 0.001f ? 0.001f : adaptionSpeed;
tonemapMaterial.SetFloat("_AdaptionSpeed", adaptionSpeed);
rt.MarkRestoreExpected(); // keeping luminance values between frames, RT restore expected
#if UNITY_EDITOR
if (Application.isPlaying && !freshlyBrewedInternalRt)
Graphics.Blit(lumRt, rt, tonemapMaterial, 2);
else
Graphics.Blit(lumRt, rt, tonemapMaterial, 3);
#else
Graphics.Blit (lumRt, rt, tonemapMaterial, freshlyBrewedInternalRt ? 3 : 2);
#endif
middleGrey = middleGrey < 0.001f ? 0.001f : middleGrey;
tonemapMaterial.SetVector("_HdrParams", new Vector4(middleGrey, middleGrey, middleGrey, white*white));
tonemapMaterial.SetTexture("_SmallTex", rt);
if (type == TonemapperType.AdaptiveReinhard)
{
Graphics.Blit(source, destination, tonemapMaterial, 0);
}
else if (type == TonemapperType.AdaptiveReinhardAutoWhite)
{
Graphics.Blit(source, destination, tonemapMaterial, 10);
}
else
{
Debug.LogError("No valid adaptive tonemapper type found!");
Graphics.Blit(source, destination); // at least we get the TransformToLDR effect
}
// cleanup for adaptive
for (int i = 0; i < downsample; i++)
{
RenderTexture.ReleaseTemporary(rts[i]);
}
RenderTexture.ReleaseTemporary(rtSquared);
}
19
Source : ColorCorrectionLookup.cs
with Apache License 2.0
from activey
with Apache License 2.0
from activey
public void Convert ( Texture2D temp2DTex, string path) {
// conversion fun: the given 2D texture needs to be of the format
// w * h, wheras h is the 'depth' (or 3d dimension 'dim') and w = dim * dim
if (temp2DTex) {
int dim = temp2DTex.width * temp2DTex.height;
dim = temp2DTex.height;
if (!ValidDimensions(temp2DTex)) {
Debug.LogWarning ("The given 2D texture " + temp2DTex.name + " cannot be used as a 3D LUT.");
basedOnTempTex = "";
return;
}
var c = temp2DTex.GetPixels();
var newC = new Color[c.Length];
for(int i = 0; i < dim; i++) {
for(int j = 0; j < dim; j++) {
for(int k = 0; k < dim; k++) {
int j_ = dim-j-1;
newC[i + (j*dim) + (k*dim*dim)] = c[k*dim+i+j_*dim*dim];
}
}
}
if (converted3DLut)
DestroyImmediate (converted3DLut);
converted3DLut = new Texture3D (dim, dim, dim, TextureFormat.ARGB32, false);
converted3DLut.SetPixels (newC);
converted3DLut.Apply ();
basedOnTempTex = path;
}
else {
// error, something went terribly wrong
Debug.LogError ("Couldn't color correct with 3D LUT texture. Image Effect will be disabled.");
}
}
19
Source : EventOSR.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public bool Handle()
{
int count = hashData.Count;
for (int i = 0; i < count; i++)
{
PhotonView view = PhotonView.Find(hashViews.Dequeue());
if (view == null)
{
//Message what view ID not exists
//Maybe put spam for invalid viewIDs, like 100 per second, idk
return true;
}
else if (view.prefix > 0 && correctPrefix != view.prefix)
{
Debug.LogError(string.Concat(new object[] { "Received OnSerialization for view ID ", view.viewID, " with prefix ", correctPrefix, ". Our prefix is ", view.prefix }));
}
if (view.observed == null)
{
myReason = $"OSR: Null observed for ViewID[{view.viewID.ToString()}]";
return false;
}
if (view.observed is MonoBehaviour)
{
PhotonStream pStream = new PhotonStream(false, hashData.Dequeue());
PhotonMessageInfo info = new PhotonMessageInfo(sender, sentTime, view);
view.ExecuteOnSerialize(pStream, info);
}
else if (view.observed is Transform)
{
Transform tf = (Transform)view.observed;
object[] arr = hashData.Dequeue();
switch (arr.Length)
{
case 1:
{
if (arr[0] == null || !(arr[0] is Vector3 vec))
{
myReason = "OSR: Null or Invalid value inside data";
return false;
}
tf.localPosition = vec;
}
break;
case 2:
{
if (arr[0] == null || !(arr[0] is Vector3 vec))
{
myReason = "OSR: Null or Invalid value inside data";
return false;
}
if (arr[1] == null || !(arr[1] is Quaternion quat))
{
myReason = "OSR: Null or Invalid value inside data";
return false;
}
tf.localPosition = vec;
tf.localRotation = quat;
break;
}
case 3:
case 4:
{
if (arr[0] == null || !(arr[0] is Vector3 vec))
{
myReason = "OSR: Null or Invalid value inside data";
return false;
}
if (arr[1] == null || !(arr[1] is Quaternion quat))
{
myReason = "OSR: Null or Invalid value inside data";
return false;
}
if (arr[2] == null || !(arr[2] is Vector3 vec1))
{
myReason = "OSR: Null or Invalid value inside data";
return false;
}
tf.localPosition = vec;
tf.localRotation = quat;
tf.localScale = vec1;
break;
}
default:
myReason = $"OSR:Invalid data length(Tf)" + arr.Length.ToString();
return false;
}
}
else if (view.observed is Rigidbody)
{
Rigidbody rb = (Rigidbody)view.observed;
object[] arr = hashData.Dequeue();
switch (arr.Length)
{
case 1:
{
if (arr[0] == null || !(arr[0] is Vector3 vec))
{
myReason = "OSR: Null or Invalid value inside data";
return false;
}
rb.velocity = vec;
break;
}
case 2:
{
if (arr[0] == null || !(arr[0] is Vector3 vec))
{
myReason = "OSR: Null or Invalid value inside data";
return false;
}
if (arr[1] == null || !(arr[1] is Vector3 loc))
{
myReason = "OSR: Null or Invalid value inside data";
return false;
}
rb.velocity = vec;
rb.angularVelocity = loc;
break;
}
default:
myReason = "OSR:Invalid data length(Rb) " + arr.Length.ToString();
return false;
}
}
else
{
//Log.Spam($"Recieved unknown observed type by [{sender.ID.ToString()}]", "UnkOSR", sender.ID);
hashData.Dequeue();
}
}
return true;
}
19
Source : EventRPC.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public bool Handle()
{
PhotonView photonView = PhotonView.Find(viewID);
if (photonView == null)
{
return true;
}
if ((photonView.Group != 0) && !PhotonNetwork.networkingPeer.allowedReceivingGroups.Contains(photonView.Group))
{
return true;
}
System.Type[] callParameterTypes = new System.Type[0];
if (parameters.Length > 0)
{
callParameterTypes = new System.Type[parameters.Length];
int index = 0;
for (int i = 0; i < parameters.Length; i++)
{
object obj2 = parameters[i];
if (obj2 == null)
{
callParameterTypes[index] = null;
}
else
{
callParameterTypes[index] = obj2.GetType();
}
index++;
}
}
int num7 = 0;
int num8 = 0;
foreach (MonoBehaviour behaviour in photonView.GetComponents<MonoBehaviour>())
{
if (behaviour == null)
{
Debug.LogError("ERROR You have missing MonoBehaviours on your gameobjects!");
}
else
{
System.Type key = behaviour.GetType();
List<MethodInfo> list = null;
if (PhotonNetwork.networkingPeer.monoRPCMethodsCache.ContainsKey(key))
{
list = PhotonNetwork.networkingPeer.monoRPCMethodsCache[key];
}
if (list == null)
{
List<MethodInfo> methods = SupportClreplaced.GetMethods(key, typeof(UnityEngine.RPC));
PhotonNetwork.networkingPeer.monoRPCMethodsCache[key] = methods;
list = methods;
}
if (list != null)
{
for (int j = 0; j < list.Count; j++)
{
MethodInfo info = list[j];
if (info.Name == name)
{
num8++;
ParameterInfo[] methodParameters = info.GetParameters();
if (methodParameters.Length == callParameterTypes.Length)
{
if (PhotonNetwork.networkingPeer.CheckTypeMatch(methodParameters, callParameterTypes))
{
num7++;
object obj3 = info.Invoke(behaviour, parameters);
if (info.ReturnType == typeof(IEnumerator))
{
behaviour.StartCoroutine((IEnumerator)obj3);
}
}
return true;
}
else if ((methodParameters.Length - 1) == callParameterTypes.Length)
{
if (PhotonNetwork.networkingPeer.CheckTypeMatch(methodParameters, callParameterTypes) && (methodParameters[methodParameters.Length - 1].ParameterType == typeof(PhotonMessageInfo)))
{
num7++;
object[] array = new object[parameters.Length + 1];
parameters.CopyTo(array, 0);
array[array.Length - 1] = new PhotonMessageInfo(sender, sTime, photonView);
object obj4 = info.Invoke(behaviour, array);
if (info.ReturnType == typeof(IEnumerator))
{
behaviour.StartCoroutine((IEnumerator)obj4);
}
}
return true;
}
else if ((methodParameters.Length == 1) && methodParameters[0].ParameterType.IsArray)
{
num7++;
object[] objArray5 = new object[] { parameters };
object obj5 = info.Invoke(behaviour, objArray5);
if (info.ReturnType == typeof(IEnumerator))
{
behaviour.StartCoroutine((IEnumerator)obj5);
}
return true;
}
return false;
}
//Log.AddLineRaw("Unknown RPC: " + name + " by ID " + sender.ID);
}
}
}
}
return true;
}
19
Source : ConfigFile.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void Load()
{
if (!System.IO.File.Exists(Path))
{
Debug.LogError($"ConfigFile Error: There is no file {Path}.");
return;
}
allValues.Clear();
booleans.Clear();
floats.Clear();
integers.Clear();
strings.Clear();
string[] allStrings = System.IO.File.ReadAllLines(Path);
foreach (string str in allStrings)
{
if (str.StartsWith("#") || str.Equals(string.Empty))
{
continue;
}
string[] add = ParseString(str);
if (add == null)
{
continue;
}
allValues.Add(add[0], add[1]);
}
}
19
Source : Language.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void SetLanguage(string lang)
{
if (AllLanguages.Contains(lang))
{
Directory = Path + lang + "/";
SelectedLanguage = lang;
Reload();
return;
}
Debug.LogError("Not found language: " + lang);
SetLanguage(DefaultLanguage);
}
19
Source : EventDI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public bool Handle()
{
GameObject res = key.StartsWith("RCreplacedet/") ? CacheResources.RCLoad(key) : (GameObject)CacheResources.Load(key);
if (res == null)
{
return false;
}
PhotonView[] photonViewsInChildren = res.GetPhotonViewsInChildren();
if (photonViewsInChildren.Length != instIDs.Length)
{
throw new System.Exception("Error in Instantiation! The resource's PhotonView count is not the same as in incoming data.");
}
for (int i = 0; i < instIDs.Length; i++)
{
photonViewsInChildren[i].viewID = instIDs[i];
photonViewsInChildren[i].prefix = prefix;
photonViewsInChildren[i].instantiationId = instID;
}
PhotonNetwork.networkingPeer.StoreInstantiationData(instID, data);
GameObject obj2 = (GameObject)UnityEngine.Object.Instantiate(res, position, rotation);
for (int j = 0; j < instIDs.Length; j++)
{
photonViewsInChildren[j].viewID = 0;
photonViewsInChildren[j].prefix = -1;
photonViewsInChildren[j].prefixBackup = -1;
photonViewsInChildren[j].instantiationId = -1;
}
PhotonNetwork.networkingPeer.RemoveInstantiationData(instID);
if (PhotonNetwork.networkingPeer.instantiatedObjects.ContainsKey(instID))
{
GameObject go = PhotonNetwork.networkingPeer.instantiatedObjects[instID];
string str2 = string.Empty;
if (go != null)
{
foreach (PhotonView view in go.GetPhotonViewsInChildren())
{
if (view != null)
{
str2 = str2 + view.ToString() + ", ";
}
}
}
object[] args = new object[] { obj2, instID, PhotonNetwork.networkingPeer.instantiatedObjects.Count, go, str2, PhotonNetwork.lastUsedViewSubId, PhotonNetwork.lastUsedViewSubIdStatic, NetworkingPeer.photonViewList.Count };
Debug.LogError(string.Format("DoInstantiate re-defines a GameObject. Destroying old entry! New: '{0}' (instantiationID: {1}) Old: {3}. PhotonViews on old: {4}. instantiatedObjects.Count: {2}. PhotonNetwork.lastUsedViewSubId: {5} PhotonNetwork.lastUsedViewSubIdStatic: {6} photonViewList.Count {7}.)", args));
PhotonNetwork.networkingPeer.RemoveInstantiatedGO(go, true);
}
PhotonNetwork.networkingPeer.instantiatedObjects.Add(instID, obj2);
obj2.SendMessage(PhotonNetworkingMessage.OnPhotonInstantiate.ToString(), new PhotonMessageInfo(sender, timeStamp, null), SendMessageOptions.DontRequireReceiver);
return true;
}
19
Source : UIManager.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private void Awake()
{
if (Instance != null)
{
Debug.LogError($"There should be only one instance of \"UIManager\". Please make sure yo spawn it just once.");
DestroyImmediate(this);
return;
}
DontDestroyOnLoad(this);
Instance = this;
onAwakeAdds();
onAwakeRms();
onAwakeAdds = delegate () { };
onAwakeRms = delegate () { };
}
19
Source : ServerListPanel.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
[GUIPage(CreationPage)]
private void RoomCreation()
{
left.Reset();
right.Reset();
LabelCenter(left, locale["roomSettings"], true);
serverName = TextField(left, serverName, locale["roomName"], Style.LabelOffset, true);
preplacedword = TextField(left, preplacedword, locale["pwd"], Style.LabelOffset, true);
serverTime = TextField(left, serverTime, locale["time"], Style.LabelOffset * 2f, true);
maxPlayers = TextField(left, maxPlayers, locale["players"], Style.LabelOffset * 2f, true);
LabelCenter(left, locale["difficulity"], true);
difficulity = SelectionGrid(left, difficulity, difficulities, difficulities.Length, true);
LabelCenter(left, locale["dayLight"], true);
daylight = SelectionGrid(left, daylight, daylights, daylights.Length, true);
left.MoveY();
LabelCenter(left, locale["presets"], true);
Label(left, locale["presetNote"], true);
newPresetName = TextField(left, newPresetName, locale["presetName"], Style.LabelOffset, true);
left.width = (left.DefaultWidth - Style.HorizontalMargin) / 2f;
if (Button(left, locale["presetAdd"], false))
{
ServerPreset set = new ServerPreset(newPresetName);
ExportPreset(set);
presets.Add(set);
presetView.height = (presets.Count * Style.Height) + ((presets.Count - 1) * Style.VerticalMargin);
set.Save();
}
left.MoveX();
if (Button(left, locale["presetRemove"], true))
{
if (presets.Count > 1)
{
ServerPreset selected = null;
for (int i = 0; i < presets.Count; i++)
{
if (presets[i].Name == newPresetName)
{
selected = presets[i];
}
}
if (selected != null)
{
presets.Remove(selected);
selected.Delete();
newPresetName = "Set " + (presets.Count + 1);
if (presets.Count > 0)
{
newPresetName = presets[presets.Count - 1].Name;
}
presetView.height = (presets.Count * Style.Height) + ((presets.Count - 1) * Style.VerticalMargin);
}
}
}
left.ResetX();
if (presets.Count > 0)
{
presetArea.y = left.y;
presetRect.Reset();
presetScroll = BeginScrollView(presetArea, presetScroll, presetView);
{
for (int i = 0; i < presets.Count; i++)
{
if (Button(presetRect, presets[i].Name, true))
{
ServerPreset selected = presets[i];
ImportPreset(selected);
}
}
}
EndScrollView();
}
left.MoveToEndY(WindowPosition, Style.Height);
left.width = left.DefaultWidth / 2f - Style.HorizontalMargin;
if (Button(left, locale["btnCreation"], false))
{
disconnectByJoin = true;
serverTime = serverTime.Trim();
int serverTimeInt;
if(!int.TryParse(serverTime, out serverTimeInt))
{
serverTimeInt = 120;
}
daylight = daylight > 2 ? 0 : daylight;
difficulity = difficulity > 2 ? 0 : difficulity;
string mapName = string.Empty;
try
{
mapName = maps[mapSelectionSetting];
}
catch(System.Exception ex)
{
Debug.LogError("Room creation exception appeared: " + ex.Message + "\n" + ex.StackTrace + $"\nSetting info: {mapSelectionSetting}");
mapSelectionSetting.Value = 0;
mapName = maps[mapSelectionSetting.Value];
}
string[] args = new string[]
{
serverName,
mapName,
new string[] { "normal", "hard", "abnormal" }[difficulity],
serverTimeInt.ToString(),
new string[] { "day", "dawn", "night" }[daylight],
preplacedword.Length > 0 ? new SimpleAES().Encrypt(preplacedword) : string.Empty,
UnityEngine.Random.Range(1000000, 10000000).ToString()
};
if (!int.TryParse(maxPlayers, out int max))
{
max = 5;
}
PhotonNetwork.CreateRoom(string.Join("`", args), new RoomOptions() { isVisible = true, isOpen = true, maxPlayers = max }, null);
DisableImmediate();
AnarchyManager.Background.Disable();
return;
}
left.MoveX(Style.HorizontalMargin, true);
if (Button(left, locale["btnOffline"], false))
{
disconnectByJoin = true;
PhotonNetwork.Disconnect();
PhotonNetwork.offlineMode = true;
string[] args = new string[]
{
serverName,
maps[mapSelectionSetting.Value],
new string[] { "normal", "hard", "abnormal" }[difficulity],
serverTime,
new string[] { "day", "dawn", "night" }[daylight],
preplacedword.Length > 0 ? new SimpleAES().Encrypt(preplacedword) : string.Empty,
UnityEngine.Random.Range(1000000, 10000000).ToString()
};
if (!int.TryParse(maxPlayers, out int max))
{
max = 5;
}
PhotonNetwork.CreateRoom(string.Join("`", args), new RoomOptions() { isVisible = true, isOpen = true, maxPlayers = max }, null);
DisableImmediate();
AnarchyManager.Background.Disable();
return;
}
LabelCenter(right, locale["mapSelection"], true);
//mapSelection = SelectionGrid(right, mapSelection, maps, 1);
DropdownMenuScrollable(this, right, mapSelectionSetting, maps, 10, true);
right.MoveY();
right.MoveY();
Label(right, LevelInfo.GetInfo(maps[mapSelectionSetting.Value], false).Description, true);
right.MoveToEndY(WindowPosition, Style.Height);
right.MoveToEndX(WindowPosition, new AutoScaleFloat(240f) + Style.HorizontalMargin);
right.width = new AutoScaleFloat(120f);
if (Button(right, locale["btnSettings"], false))
{
connected = false;
pageSelection = SettingsPage;
return;
}
right.MoveX();
if (Button(right, locale["btnList"], false))
{
connected = PhotonNetwork.connected;
if (connected)
{
timeToUpdate = 0.1f;
}
pageSelection = ServerListPage;
return;
}
}
19
Source : GUIBase.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private static int GetLayer(int layerToSet, string name)
{
lock (usedLayers)
{
if (layerToSet >= 0)
{
if (usedLayers.Contains(layerToSet))
{
Debug.LogError($"Attemption to create GUIBase with already existing layer. Please make sure you wanted to use this one. Layer: {layerToSet}, GUIBase name: {name}");
return GetLayer(++layerToSet, name);
}
usedLayers.Add(layerToSet);
UpdateMaxLayer();
return layerToSet;
}
maxLayer = usedLayers.Max();
usedLayers.Add(++maxLayer);
return maxLayer;
}
}
19
Source : GUIBase.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public Texture2D LoadTexture(string namebase, string ext)
{
if (textureCache.TryGetValue(namebase, out Texture2D res) && res != null)
{
return res;
}
string name = namebase;
bool error = false;
if (ext == string.Empty)
{
if (!name.EndsWith(".png") && !name.EndsWith(".jpg") && !name.EndsWith(".jpeg"))
{
error = true;
}
}
else
{
if (!ext.Equals("png") && !ext.Equals("jpg") && !ext.Equals("jpeg"))
{
error = true;
}
name += "." + ext;
}
if (error)
{
Debug.LogError($"You should use png, jpg or jpeg extensions for loading Texture2D");
return Texture2D.blackTexture;
}
string path = Directory + name;
if (!File.Exists(path))
{
Debug.LogError($"File what you are trying to load doesnt't exist: \"{path}\"");
return Texture2D.blackTexture;
}
res = new Texture2D(1, 1, TextureFormat.RGBA32, false);
res.LoadImage(File.ReadAllBytes(path));
res.Apply();
textureCache.Add(namebase, res);
return res;
}
19
Source : GUIBase.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public MovieTexture LoadVideo(string namebase)
{
MovieTexture tex;
string name = namebase;
string path = Directory + name + ".ogv";
if (!File.Exists(path))
{
Debug.LogError($"File what you are trying to load doesnt't exist: \"{path}\"");
return null;
}
WWW www = new WWW("file://" + path);
if (www.texture == null)
{
Debug.LogError($"Null texture");
www.Dispose();
GC.SuppressFinalize(www);
return null;
}
tex = www.movie;
www.Dispose();
GC.SuppressFinalize(www);
return tex;
}
19
Source : AnarchyAssets.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static System.Collections.IEnumerator LoadreplacedetBundle()
{
replacedetBundleCreateRequest bundle = replacedetBundle.CreateFromMemory(File.ReadAllBytes(BundlePath));
yield return bundle;
if (bundle == null)
{
Debug.LogError($"Error while loading Anarchyreplacedets. Make sure that file \"{BundlePath}\" exists.");
yield break;
}
Bundle = bundle.replacedetBundle;
}
19
Source : COLOSSAL_TITAN.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
[RPC]
private void loadskinRPC(string url, PhotonMessageInfo info = null)
{
if (SkinSettings.replacedanSkins.Value == 1 && info != null && info.Sender.IsMasterClient && Anarchy.Network.Antis.IsValidSkinURL(ref url, 1, info.Sender.ID))
{
if (mySkin != null)
{
Debug.LogError($"Someone tries to reload existing {GetType().Name} skin");
return;
}
StartCoroutine(LoadMySkin(url));
}
}
19
Source : COLOSSAL_TITAN.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
[RPC]
private void loadskinRPC(string url, PhotonMessageInfo info = null)
{
if(SkinSettings.replacedanSkins.Value == 1 && info != null && info.Sender.IsMasterClient)
{
if(mySkin != null)
{
Debug.LogError($"Someone tries to reload existing {GetType().Name} skin");
return;
}
StartCoroutine(LoadMySkin(url));
}
}
19
Source : FengPhotonCalls.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void OnPhotonCreateRoomFailed(AOTEventArgs args)
{
Debug.LogError("OnPhotonCreateRoomFailed");
}
19
Source : InputManager.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private void Awake()
{
if (instance != null)
{
DestroyImmediate(this);
Debug.LogError("Attemption to create more then one Anarchy.InputManager, please avoid this");
return;
}
DontDestroyOnLoad(this);
instance = this;
if (AllKeys == null)
{
InitList();
}
onAwake?.Invoke();
onAwake = null;
}
19
Source : FengGameManagerMKII.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void MultiplayerRacingFinish()
{
Debug.LogError(nameof(MultiplayerRacingFinish));
var num = logic.RoundTime - ((RacingLogic)logic).StartTime;
if (PhotonNetwork.IsMasterClient)
{
getRacingResult(User.RaceName, num);
}
else
{
BasePV.RPC("getRacingResult", PhotonTargets.MasterClient, User.RaceName, num);
}
GameWin();
}
19
Source : UIDrawCall.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void Set(BetterList<Vector3> verts, BetterList<Vector3> norms, BetterList<Vector4> tans, BetterList<Vector2> uvs, BetterList<Color32> cols)
{
int size = verts.size;
if (size > 0 && size == uvs.size && size == cols.size && size % 4 == 0)
{
if (this.mFilter == null)
{
this.mFilter = base.gameObject.GetComponent<MeshFilter>();
}
if (this.mFilter == null)
{
this.mFilter = base.gameObject.AddComponent<MeshFilter>();
}
if (this.mRen == null)
{
this.mRen = base.gameObject.GetComponent<MeshRenderer>();
}
if (this.mRen == null)
{
this.mRen = base.gameObject.AddComponent<MeshRenderer>();
this.UpdateMaterials();
}
else if (this.mClippedMat != null && this.mClippedMat.mainTexture != this.mSharedMat.mainTexture)
{
this.UpdateMaterials();
}
if (verts.size < 65000)
{
int num = (size >> 1) * 3;
bool flag = this.mIndices == null || this.mIndices.Length != num;
if (flag)
{
this.mIndices = new int[num];
int num2 = 0;
for (int i = 0; i < size; i += 4)
{
this.mIndices[num2++] = i;
this.mIndices[num2++] = i + 1;
this.mIndices[num2++] = i + 2;
this.mIndices[num2++] = i + 2;
this.mIndices[num2++] = i + 3;
this.mIndices[num2++] = i;
}
}
Mesh mesh = this.GetMesh(ref flag, verts.size);
mesh.vertices = verts.ToArray();
if (norms != null)
{
mesh.normals = norms.ToArray();
}
if (tans != null)
{
mesh.tangents = tans.ToArray();
}
mesh.uv = uvs.ToArray();
mesh.colors32 = cols.ToArray();
if (flag)
{
mesh.triangles = this.mIndices;
}
mesh.RecalculateBounds();
this.mFilter.mesh = mesh;
}
else
{
if (this.mFilter.mesh != null)
{
this.mFilter.mesh.Clear();
}
Debug.LogError("Too many vertices on one panel: " + verts.size);
}
}
else
{
if (this.mFilter.mesh != null)
{
this.mFilter.mesh.Clear();
}
Debug.LogError("UIWidgets must fill the buffer with 4 vertices per quad. Found " + size);
}
}
19
Source : UIFont.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void Print(string text, Color32 color, BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols, bool encoding, UIFont.SymbolStyle symbolStyle, UIFont.Alignment alignment, int lineWidth, bool premultiply)
{
if (this.mReplacement != null)
{
this.mReplacement.Print(text, color, verts, uvs, cols, encoding, symbolStyle, alignment, lineWidth, premultiply);
}
else if (text != null)
{
if (!this.isValid)
{
Debug.LogError("Attempting to print using an invalid font!");
return;
}
bool isDynamic = this.isDynamic;
if (isDynamic)
{
this.mDynamicFont.textureRebuildCallback = new Font.FontTextureRebuildCallback(this.OnFontChanged);
this.mDynamicFont.RequestCharactersInTexture(text, this.mDynamicFontSize, this.mDynamicFontStyle);
this.mDynamicFont.textureRebuildCallback = null;
}
this.mColors.Clear();
this.mColors.Add(color);
int size = this.size;
Vector2 vector = (size <= 0) ? Vectors.v2one : new Vector2(1f / (float)size, 1f / (float)size);
int size2 = verts.size;
int num = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
int num5 = size + this.mSpacingY;
Vector3 zero = Vectors.zero;
Vector3 zero2 = Vectors.zero;
Vector2 zero3 = Vectors.v2zero;
Vector2 zero4 = Vectors.v2zero;
float num6 = this.uvRect.width / (float)this.mFont.texWidth;
float num7 = this.mUVRect.height / (float)this.mFont.texHeight;
int length = text.Length;
bool flag = encoding && symbolStyle != UIFont.SymbolStyle.None && this.hreplacedymbols && this.sprite != null;
for (int i = 0; i < length; i++)
{
char c = text[i];
if (c == '\n')
{
if (num2 > num)
{
num = num2;
}
if (alignment != UIFont.Alignment.Left)
{
this.Align(verts, size2, alignment, num2, lineWidth);
size2 = verts.size;
}
num2 = 0;
num3 += num5;
num4 = 0;
}
else if (c < ' ')
{
num4 = 0;
}
else
{
if (encoding && c == '[')
{
int num8 = NGUITools.ParseSymbol(text, i, this.mColors, premultiply);
if (num8 > 0)
{
color = this.mColors[this.mColors.Count - 1];
i += num8 - 1;
goto IL_96C;
}
}
if (!isDynamic)
{
BMSymbol bmsymbol = (!flag) ? null : this.MatchSymbol(text, i, length);
if (bmsymbol == null)
{
BMGlyph glyph = this.mFont.GetGlyph((int)c);
if (glyph == null)
{
goto IL_96C;
}
if (num4 != 0)
{
num2 += glyph.GetKerning(num4);
}
if (c == ' ')
{
num2 += this.mSpacingX + glyph.advance;
num4 = (int)c;
goto IL_96C;
}
zero.x = vector.x * (float)(num2 + glyph.offsetX);
zero.y = -vector.y * (float)(num3 + glyph.offsetY);
zero2.x = zero.x + vector.x * (float)glyph.width;
zero2.y = zero.y - vector.y * (float)glyph.height;
zero3.x = this.mUVRect.xMin + num6 * (float)glyph.x;
zero3.y = this.mUVRect.yMax - num7 * (float)glyph.y;
zero4.x = zero3.x + num6 * (float)glyph.width;
zero4.y = zero3.y - num7 * (float)glyph.height;
num2 += this.mSpacingX + glyph.advance;
num4 = (int)c;
if (glyph.channel == 0 || glyph.channel == 15)
{
for (int j = 0; j < 4; j++)
{
cols.Add(color);
}
}
else
{
Color color2 = color;
color2 *= 0.49f;
switch (glyph.channel)
{
case 1:
color2.b += 0.51f;
break;
case 2:
color2.g += 0.51f;
break;
case 4:
color2.r += 0.51f;
break;
case 8:
color2.a += 0.51f;
break;
}
for (int k = 0; k < 4; k++)
{
cols.Add(color2);
}
}
}
else
{
zero.x = vector.x * (float)(num2 + bmsymbol.offsetX);
zero.y = -vector.y * (float)(num3 + bmsymbol.offsetY);
zero2.x = zero.x + vector.x * (float)bmsymbol.width;
zero2.y = zero.y - vector.y * (float)bmsymbol.height;
Rect uvRect = bmsymbol.uvRect;
zero3.x = uvRect.xMin;
zero3.y = uvRect.yMax;
zero4.x = uvRect.xMax;
zero4.y = uvRect.yMin;
num2 += this.mSpacingX + bmsymbol.advance;
i += bmsymbol.length - 1;
num4 = 0;
if (symbolStyle == UIFont.SymbolStyle.Colored)
{
for (int l = 0; l < 4; l++)
{
cols.Add(color);
}
}
else
{
Color32 item = Color.white;
item.a = color.a;
for (int m = 0; m < 4; m++)
{
cols.Add(item);
}
}
}
verts.Add(new Vector3(zero2.x, zero.y));
verts.Add(new Vector3(zero2.x, zero2.y));
verts.Add(new Vector3(zero.x, zero2.y));
verts.Add(new Vector3(zero.x, zero.y));
uvs.Add(new Vector2(zero4.x, zero3.y));
uvs.Add(new Vector2(zero4.x, zero4.y));
uvs.Add(new Vector2(zero3.x, zero4.y));
uvs.Add(new Vector2(zero3.x, zero3.y));
}
else if (this.mDynamicFont.GetCharacterInfo(c, out UIFont.mChar, this.mDynamicFontSize, this.mDynamicFontStyle))
{
zero.x = vector.x * ((float)num2 + UIFont.mChar.vert.xMin);
zero.y = -vector.y * ((float)num3 - UIFont.mChar.vert.yMax + this.mDynamicFontOffset);
zero2.x = zero.x + vector.x * UIFont.mChar.vert.width;
zero2.y = zero.y - vector.y * UIFont.mChar.vert.height;
zero3.x = UIFont.mChar.uv.xMin;
zero3.y = UIFont.mChar.uv.yMin;
zero4.x = UIFont.mChar.uv.xMax;
zero4.y = UIFont.mChar.uv.yMax;
num2 += this.mSpacingX + (int)UIFont.mChar.width;
for (int n = 0; n < 4; n++)
{
cols.Add(color);
}
if (UIFont.mChar.flipped)
{
uvs.Add(new Vector2(zero3.x, zero4.y));
uvs.Add(new Vector2(zero3.x, zero3.y));
uvs.Add(new Vector2(zero4.x, zero3.y));
uvs.Add(new Vector2(zero4.x, zero4.y));
}
else
{
uvs.Add(new Vector2(zero4.x, zero3.y));
uvs.Add(new Vector2(zero3.x, zero3.y));
uvs.Add(new Vector2(zero3.x, zero4.y));
uvs.Add(new Vector2(zero4.x, zero4.y));
}
verts.Add(new Vector3(zero2.x, zero.y));
verts.Add(new Vector3(zero.x, zero.y));
verts.Add(new Vector3(zero.x, zero2.y));
verts.Add(new Vector3(zero2.x, zero2.y));
}
}
IL_96C:;
}
if (alignment != UIFont.Alignment.Left && size2 < verts.size)
{
this.Align(verts, size2, alignment, num2, lineWidth);
size2 = verts.size;
}
}
}
19
Source : UIRoot.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void Broadcast(string funcName, object param)
{
if (param == null)
{
Debug.LogError("SendMessage is bugged when you try to preplaced 'null' in the parameter field. It behaves as if no parameter was specified.");
}
else
{
int i = 0;
int count = UIRoot.mRoots.Count;
while (i < count)
{
UIRoot uiroot = UIRoot.mRoots[i];
if (uiroot != null)
{
uiroot.BroadcastMessage(funcName, param, SendMessageOptions.DontRequireReceiver);
}
i++;
}
}
}
19
Source : NGUITools.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static WWW OpenURL(string url)
{
WWW result = null;
try
{
result = new WWW(url);
}
catch (Exception ex)
{
Debug.LogError(ex.Message);
}
return result;
}
19
Source : NGUITools.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static WWW OpenURL(string url, WWWForm form)
{
if (form == null)
{
return NGUITools.OpenURL(url);
}
WWW result = null;
try
{
result = new WWW(url, form);
}
catch (Exception ex)
{
Debug.LogError((ex == null) ? "<null>" : ex.Message);
}
return result;
}
19
Source : ManualPhotonViewAllocator.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void AllocateManualPhotonView()
{
PhotonView photonView = base.gameObject.GetPhotonView();
if (photonView == null)
{
Debug.LogError("Can't do manual instantiation without PhotonView component.");
return;
}
int num = PhotonNetwork.AllocateViewID();
photonView.RPC("InstantiateRpc", PhotonTargets.AllBuffered, new object[]
{
num
});
}
19
Source : PhotonHandler.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void DebugReturn(DebugLevel level, string message)
{
if (level == DebugLevel.ERROR)
{
Debug.LogError(message);
}
else if (level == DebugLevel.WARNING)
{
Debug.LogWarning(message);
}
else if (level == DebugLevel.INFO && PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
{
Debug.Log(message);
}
else if (level == DebugLevel.ALL && PhotonNetwork.logLevel == PhotonLogLevel.Full)
{
Debug.Log(message);
}
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private static bool VerifyCreplacedeNetwork()
{
if (connected)
{
return true;
}
Debug.LogError("Cannot send messages when not connected. Either connect to Photon OR use offline mode!");
return false;
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
internal static void RPC(PhotonView view, string methodName, PhotonPlayer targetPlayer, params object[] parameters)
{
if (!VerifyCreplacedeNetwork())
{
return;
}
if (room == null)
{
Debug.LogWarning("Cannot send RPCs in Lobby, only processed locally");
return;
}
if (player == null)
{
Debug.LogError("Error; Sending RPC to player null! Aborted \"" + methodName + "\"");
}
if (networkingPeer != null)
{
networkingPeer.RPC(view, methodName, targetPlayer, parameters);
}
else
{
Debug.LogWarning("Could not execute RPC " + methodName + ". Possible scene loading in progress?");
}
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool CloseConnection(PhotonPlayer kickPlayer)
{
if (!VerifyCreplacedeNetwork())
{
return false;
}
if (!player.IsMasterClient)
{
Debug.LogError("CloseConnection: Only the masterclient can kick another player.");
return false;
}
if (kickPlayer == null)
{
Debug.LogError("CloseConnection: No such player connected!");
return false;
}
RaiseEventOptions raiseEventOptions = new RaiseEventOptions
{
TargetActors = new int[]
{
kickPlayer.ID
}
};
return networkingPeer.OpRaiseEvent(203, null, true, raiseEventOptions);
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool ConnectUsingSettings(string gameVersion)
{
if (PhotonServerSettings == null)
{
Debug.LogError("Can't connect: Loading settings failed. ServerSettings replacedet must be in any 'Resources' folder as: PhotonServerSettings");
return false;
}
SwitchToProtocol(PhotonServerSettings.Protocol);
networkingPeer.SetApp(PhotonServerSettings.AppID, gameVersion);
if (PhotonServerSettings.HostType == ServerSettings.HostingOption.OfflineMode)
{
offlineMode = true;
return true;
}
if (offlineMode)
{
Debug.LogWarning("ConnectUsingSettings() disabled the offline mode. No longer offline.");
}
offlineMode = false;
isMessageQueueRunning = true;
networkingPeer.IsInitialConnect = true;
if (PhotonServerSettings.HostType == ServerSettings.HostingOption.SelfHosted)
{
networkingPeer.IsUsingNameServer = false;
networkingPeer.MasterServerAddress = PhotonServerSettings.ServerAddress + ":" + PhotonServerSettings.ServerPort;
return networkingPeer.Connect(networkingPeer.MasterServerAddress, ServerConnection.MasterServer);
}
if (PhotonServerSettings.HostType == ServerSettings.HostingOption.BestRegion)
{
return ConnectToBestCloudServer(gameVersion);
}
return networkingPeer.ConnectToRegionMaster(PhotonServerSettings.PreferredRegion);
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool CreateRoom(string roomName, RoomOptions roomOptions, TypedLobby typedLobby)
{
if (offlineMode)
{
if (offlineModeRoom != null)
{
Debug.LogError("CreateRoom failed. In offline mode you still have to leave a room to enter another.");
return false;
}
offlineModeRoom = new Room(roomName, roomOptions);
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom, new object[0]);
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnCreatedRoom, new object[0]);
return true;
}
else
{
if (networkingPeer.server != ServerConnection.MasterServer || !connectedAndReady)
{
Debug.LogError("CreateRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
return false;
}
return networkingPeer.OpCreateGame(roomName, roomOptions, typedLobby);
}
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void Destroy(PhotonView targetView)
{
if (targetView != null)
{
networkingPeer.RemoveInstantiatedGO(targetView.gameObject, !inRoom);
}
else
{
Debug.LogError("Destroy(targetPhotonView) failed, cause targetPhotonView is null.");
}
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void DestroyAll()
{
if (IsMasterClient)
{
networkingPeer.DestroyAll(false);
}
else
{
Debug.LogError("Couldn't call DestroyAll() as only the master client is allowed to call this.");
}
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void DestroyPlayerObjects(PhotonPlayer targetPlayer)
{
if (targetPlayer == null)
{
Debug.LogError("DestroyPlayerObjects() failed, cause parameter 'targetPlayer' was null.");
}
DestroyPlayerObjects(targetPlayer.ID);
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void DestroyPlayerObjects(int targetPlayerId)
{
if (!VerifyCreplacedeNetwork())
{
return;
}
if (player.IsMasterClient || targetPlayerId == player.ID)
{
networkingPeer.DestroyPlayerObjects(targetPlayerId, false);
}
else
{
Debug.LogError("DestroyPlayerObjects() failed, cause players can only destroy their own GameObjects. A Master Client can destroy anyone's. This is master: " + IsMasterClient);
}
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static GameObject Instantiate(string prefabName, Vector3 position, Quaternion rotation, int group, object[] data)
{
if (!connected || (InstantiateInRoomOnly && !inRoom))
{
Debug.LogError(string.Concat(new object[]
{
"Failed to Instantiate prefab: ",
prefabName,
". Client should be in a room. Current connectionStateDetailed: ",
connectionStateDetailed
}));
return null;
}
GameObject gameObject = prefabName.StartsWith("RCreplacedet/") ? Optimization.Caching.CacheResources.RCLoad(prefabName) : (GameObject)Optimization.Caching.CacheResources.Load(prefabName);
// if (!UsePrefabCache || !PrefabCache.TryGetValue(prefabName, out gameObject))
//{
// gameObject =
// if (UsePrefabCache)
// {
// PrefabCache.Add(prefabName, gameObject);
// }
//}
if (gameObject == null)
{
Debug.LogError("Failed to Instantiate prefab: " + prefabName + ". Verify the Prefab is in a Resources folder (and not in a subfolder)");
return null;
}
if (gameObject.GetComponent<PhotonView>() == null)
{
Debug.LogError("Failed to Instantiate prefab:" + prefabName + ". Prefab must have a PhotonView component.");
return null;
}
Component[] photonViewsInChildren = gameObject.GetPhotonViewsInChildren();
int[] array = new int[photonViewsInChildren.Length];
for (int i = 0; i < array.Length; i++)
{
array[i] = AllocateViewID(player.ID);
}
networkingPeer.SendInstantiate(prefabName, position, rotation, group, array, data, false);
return Optimization.Caching.Pool.NetworkInstantiate(prefabName, position, rotation, array[0], array, networkingPeer.currentLevelPrefix, group, data);
//Hashtable evData = networkingPeer.SendInstantiate(prefabName, position, rotation, group, array, data, false);
//return networkingPeer.DoInstantiate(evData, networkingPeer.mLocalActor, gameObject);
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static GameObject InstantiateSceneObject(string prefabName, Vector3 position, Quaternion rotation, int group, object[] data)
{
if (!connected || (InstantiateInRoomOnly && !inRoom))
{
Debug.LogError(string.Concat(new object[]
{
"Failed to InstantiateSceneObject prefab: ",
prefabName,
". Client should be in a room. Current connectionStateDetailed: ",
connectionStateDetailed
}));
return null;
}
if (!IsMasterClient)
{
Debug.LogError("Failed to InstantiateSceneObject prefab: " + prefabName + ". Client is not the MasterClient in this room.");
return null;
}
GameObject gameObject = (GameObject)Optimization.Caching.CacheResources.Load(prefabName);
if (gameObject == null)
{
Debug.LogError("Failed to InstantiateSceneObject prefab: " + prefabName + ". Verify the Prefab is in a Resources folder (and not in a subfolder)");
return null;
}
if (gameObject.GetComponent<PhotonView>() == null)
{
Debug.LogError("Failed to InstantiateSceneObject prefab:" + prefabName + ". Prefab must have a PhotonView component.");
return null;
}
Component[] photonViewsInChildren = gameObject.GetPhotonViewsInChildren();
int[] array = AllocateSceneViewIDs(photonViewsInChildren.Length);
if (array == null)
{
Debug.LogError(string.Concat(new object[]
{
"Failed to InstantiateSceneObject prefab: ",
prefabName,
". No ViewIDs are free to use. Max is: ",
MAX_VIEW_IDS
}));
return null;
}
Hashtable evData = networkingPeer.SendInstantiate(prefabName, position, rotation, group, array, data, true);
return networkingPeer.DoInstantiate(evData, networkingPeer.mLocalActor, gameObject);
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool JoinOrCreateRoom(string roomName, RoomOptions roomOptions, TypedLobby typedLobby)
{
if (offlineMode)
{
if (offlineModeRoom != null)
{
Debug.LogError("JoinOrCreateRoom failed. In offline mode you still have to leave a room to enter another.");
return false;
}
offlineModeRoom = new Room(roomName, roomOptions);
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom, new object[0]);
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnCreatedRoom, new object[0]);
return true;
}
else
{
if (networkingPeer.server != ServerConnection.MasterServer || !connectedAndReady)
{
Debug.LogError("JoinOrCreateRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
return false;
}
if (string.IsNullOrEmpty(roomName))
{
Debug.LogError("JoinOrCreateRoom failed. A roomname is required. If you don't know one, how will you join?");
return false;
}
return networkingPeer.OpJoinRoom(roomName, roomOptions, typedLobby, true);
}
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
{
if (offlineMode)
{
if (offlineModeRoom != null)
{
Debug.LogError("JoinRandomRoom failed. In offline mode you still have to leave a room to enter another.");
return false;
}
offlineModeRoom = new Room("offline room", null);
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom, new object[0]);
return true;
}
else
{
if (networkingPeer.server != ServerConnection.MasterServer || !connectedAndReady)
{
Debug.LogError("JoinRandomRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
return false;
}
Hashtable hashtable = new Hashtable();
hashtable.MergeStringKeys(expectedCustomRoomProperties);
if (expectedMaxPlayers > 0)
{
hashtable[byte.MaxValue] = expectedMaxPlayers;
}
return networkingPeer.OpJoinRandomRoom(hashtable, 0, null, matchingType, typedLobby, sqlLobbyFilter);
}
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
[Obsolete("Use overload with roomOptions and TypedLobby parameter.")]
public static bool JoinRoom(string roomName, bool createIfNotExists)
{
if (connectionStateDetailed == PeerState.Joining || connectionStateDetailed == PeerState.Joined || connectionStateDetailed == PeerState.ConnectedToGameserver)
{
Debug.LogError("JoinRoom aborted: You can only join a room while not currently connected/connecting to a room.");
}
else if (room != null)
{
Debug.LogError("JoinRoom aborted: You are already in a room!");
}
else if (roomName == string.Empty)
{
Debug.LogError("JoinRoom aborted: You must specifiy a room name!");
}
else
{
if (offlineMode)
{
offlineModeRoom = new Room(roomName, null);
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom, new object[0]);
return true;
}
return networkingPeer.OpJoinRoom(roomName, null, null, createIfNotExists);
}
return false;
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool JoinRoom(string roomName)
{
if (offlineMode)
{
if (offlineModeRoom != null)
{
Debug.LogError("JoinRoom failed. In offline mode you still have to leave a room to enter another.");
return false;
}
offlineModeRoom = new Room(roomName, null);
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom, new object[0]);
return true;
}
else
{
if (networkingPeer.server != ServerConnection.MasterServer || !connectedAndReady)
{
Debug.LogError("JoinRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
return false;
}
if (string.IsNullOrEmpty(roomName))
{
Debug.LogError("JoinRoom failed. A roomname is required. If you don't know one, how will you join?");
return false;
}
return networkingPeer.OpJoinRoom(roomName, null, null, false);
}
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void RemoveRPCs(PhotonPlayer targetPlayer)
{
if (!VerifyCreplacedeNetwork())
{
return;
}
if (!targetPlayer.IsLocal && !IsMasterClient)
{
Debug.LogError("Error; Only the MasterClient can call RemoveRPCs for other players.");
return;
}
networkingPeer.OpCleanRpcBuffer(targetPlayer.ID);
}
19
Source : PhotonPlayer.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
internal void InternalChangeLocalID(int newID)
{
if (!this.IsLocal)
{
Debug.LogError("ERROR You should never change PhotonPlayer IDs!");
return;
}
var info = GetType().GetField(nameof(ID), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
if (info != null)
{
info.SetValue(this, newID);
InitializeCounters();
}
targetArray[0] = ID;
}
19
Source : Pool.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static GameObject NetworkInstantiate(string name, Vector3 position, Quaternion rotation, int instantioationId, int[] viewIDs, short prefix = 0, int group = 0, object[] data = null)
{
GameObject res = (name.StartsWith("RCreplacedet/") ? CacheResources.RCLoad(name) : CacheResources.Load(name)) as GameObject;
if (res == null)
{
Debug.LogError($"Pool.NetworkInstantiate(): Cannot fint prefab with name \"{name}\".");
return null;
}
PhotonView[] views = res.GetPhotonViewsInChildren();
if (views.Length != viewIDs.Length)
{
throw new System.Exception($"Pool.NetworkInstantiate(): Error in Instantiation(\"{name}\")! The resource's PhotonView count is not the same as in incoming data. {views.Length} != {viewIDs.Length}");
}
for (int i = 0; i < views.Length; i++)
{
views[i].viewID = viewIDs[i];
views[i].prefix = prefix;
views[i].instantiationId = instantioationId;
}
PhotonNetwork.networkingPeer.StoreInstantiationData(instantioationId, data);
GameObject go = (GameObject)Object.Instantiate(res, position, rotation);
for (int i = 0; i < views.Length; i++)
{
views[i].viewID = 0;
views[i].prefix = -1;
views[i].instantiationId = -1;
views[i].prefixBackup = -1;
}
PhotonNetwork.networkingPeer.RemoveInstantiationData(instantioationId);
if (PhotonNetwork.networkingPeer.instantiatedObjects.ContainsKey(instantioationId))
{
GameObject gameobj = PhotonNetwork.networkingPeer.instantiatedObjects[instantioationId];
string str2 = string.Empty;
if (gameobj != null)
{
foreach (PhotonView view in gameobj.GetPhotonViewsInChildren())
{
if (view != null)
{
str2 = str2 + view.ToString() + ", ";
}
}
}
object[] args = new object[] { gameobj, instantioationId, PhotonNetwork.networkingPeer.instantiatedObjects.Count, go, str2, PhotonNetwork.lastUsedViewSubId, PhotonNetwork.lastUsedViewSubIdStatic, NetworkingPeer.photonViewList.Count };
Debug.LogError(string.Format("DoInstantiate re-defines a GameObject. Destroying old entry! New: '{0}' (instantiationID: {1}) Old: {3}. PhotonViews on old: {4}. instantiatedObjects.Count: {2}. PhotonNetwork.lastUsedViewSubId: {5} PhotonNetwork.lastUsedViewSubIdStatic: {6} photonViewList.Count {7}.)", args));
PhotonNetwork.networkingPeer.RemoveInstantiatedGO(go, true);
}
PhotonNetwork.networkingPeer.instantiatedObjects.Add(instantioationId, go);
return go;
}
19
Source : PoolObject.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public GameObject NetworkEnable(string name, Vector3 position, Quaternion rotation, int group = 0, object[] data = null, bool isSceneObject = false)
{
if (IN_GAME_MAIN_CAMERA.GameType != GameType.MultiPlayer)
{
Debug.LogError($"PoolObject.NetworkEnable(): Failed to NetworkEnable prefab, because GameType is not Multiplayer.");
return null;
}
GameObject go = PickObject(name);
PhotonView pv = go.GetComponent<PhotonView>();
if (pv == null)
{
throw new System.Exception($"PoolObject.NetworkEnable(): Prefab \"{name}\" has not PhotonView component.");
}
PhotonView[] photonViews = go.GetPhotonViewsInChildren();
int[] viewIDs = new int[photonViews.Length];
for (int i = 0; i < viewIDs.Length; i++)
{
viewIDs[i] = PhotonNetwork.AllocateViewID(PhotonNetwork.player.ID);
}
PhotonNetwork.networkingPeer.SendInstantiate(name, position, rotation, group, viewIDs, data, isSceneObject);
return NetworkInstantiate(name, position, rotation, viewIDs[0], viewIDs, (short)(PhotonNetwork.networkingPeer.currentLevelPrefix > 0 ? PhotonNetwork.networkingPeer.currentLevelPrefix : 0), group, data);
#region Old version
//for (int i = 0; i < photonViews.Length; i++)
//{
// photonViews[i].viewID = viewIDs[i];
// photonViews[i].prefix = prefix;
// photonViews[i].instantiationId = instantiationId;
//}
//if (go.transform != null)
//{
// go.transform.position = position;
// go.transform.rotation = rotation;
//}
//peer.StoreInstantiationData(instantiationId, data);
//go.SetActive(true);
//peer.RemoveInstantiationData(instantiationId);
//if (peer.instantiatedObjects.ContainsKey(instantiationId))
//{
// GameObject gameobj = peer.instantiatedObjects[instantiationId];
// string str2 = string.Empty;
// if (gameobj != null)
// {
// foreach (PhotonView view in gameobj.GetPhotonViewsInChildren())
// {
// if (view != null)
// {
// str2 = str2 + view.ToString() + ", ";
// }
// }
// }
// object[] args = new object[] { gameobj, instantiationId, peer.instantiatedObjects.Count, go, str2, PhotonNetwork.lastUsedViewSubId, PhotonNetwork.lastUsedViewSubIdStatic, NetworkingPeer.photonViewList.Count };
// Debug.LogError(string.Format("DoInstantiate re-defines a GameObject. Destroying old entry! New: '{0}' (instantiationID: {1}) Old: {3}. PhotonViews on old: {4}. instantiatedObjects.Count: {2}. PhotonNetwork.lastUsedViewSubId: {5} PhotonNetwork.lastUsedViewSubIdStatic: {6} photonViewList.Count {7}.)", args));
// peer.RemoveInstantiatedGO(go, true);
//}
//peer.instantiatedObjects.Add(instantiationId, go);
//return go;
#endregion Old version
}
19
Source : PoolObject.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public GameObject NetworkInstantiate(string name, Vector3 position, Quaternion rotation, int instantioationId, int[] viewIDs, short prefix = 0, int group = 0, object[] data = null)
{
GameObject go = PickObject(name);
if (!go.GetComponent<PhotonView>())
{
Debug.LogError($"PoolObject.NetworkInstantiate(): Prefab with name \"{name}\" has not PhotonView component!");
return null;
}
PhotonView[] views = go.GetPhotonViewsInChildren();
for (int i = 0; i < views.Length; i++)
{
views[i].didAwake = false;
views[i].viewID = 0;
views[i].prefix = prefix;
views[i].instantiationId = instantioationId;
views[i].instantiationData = data;
views[i].didAwake = true;
views[i].viewID = viewIDs[i];
}
if (go.transform)
{
go.transform.position = position;
go.transform.rotation = rotation;
}
go.SetActive(true);
PhotonNetwork.networkingPeer.RemoveInstantiationData(instantioationId);
if (PhotonNetwork.networkingPeer.instantiatedObjects.ContainsKey(instantioationId))
{
GameObject gameobj = PhotonNetwork.networkingPeer.instantiatedObjects[instantioationId];
string str2 = string.Empty;
if (gameobj != null)
{
foreach (PhotonView view in gameobj.GetPhotonViewsInChildren())
{
if (view != null)
{
str2 = str2 + view.ToString() + ", ";
}
}
}
object[] args = new object[] { gameobj, instantioationId, PhotonNetwork.networkingPeer.instantiatedObjects.Count, go, str2, PhotonNetwork.lastUsedViewSubId, PhotonNetwork.lastUsedViewSubIdStatic, NetworkingPeer.photonViewList.Count };
Debug.LogError(string.Format("DoInstantiate re-defines a GameObject. Destroying old entry! New: '{0}' (instantiationID: {1}) Old: {3}. PhotonViews on old: {4}. instantiatedObjects.Count: {2}. PhotonNetwork.lastUsedViewSubId: {5} PhotonNetwork.lastUsedViewSubIdStatic: {6} photonViewList.Count {7}.)", args));
PhotonNetwork.networkingPeer.RemoveInstantiatedGO(go, true);
}
PhotonNetwork.networkingPeer.instantiatedObjects.Add(instantioationId, go);
return go;
}
19
Source : PhotonNetwork.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool ConnectToBestCloudServer(string gameVersion)
{
if (PhotonServerSettings == null)
{
Debug.LogError("Can't connect: Loading settings failed. ServerSettings replacedet must be in any 'Resources' folder as: PhotonServerSettings");
return false;
}
if (PhotonServerSettings.HostType == ServerSettings.HostingOption.OfflineMode)
{
return ConnectUsingSettings(gameVersion);
}
networkingPeer.IsInitialConnect = true;
networkingPeer.SetApp(PhotonServerSettings.AppID, gameVersion);
CloudRegionCode bestRegionCodeInPreferences = PhotonHandler.BestRegionCodeInPreferences;
if (bestRegionCodeInPreferences != CloudRegionCode.none)
{
Debug.Log("Best region found in PlayerPrefs. Connecting to: " + bestRegionCodeInPreferences);
return networkingPeer.ConnectToRegionMaster(bestRegionCodeInPreferences);
}
return networkingPeer.ConnectToNameServer();
}
19
Source : EffectLayer.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void AddActiveNode(EffectNode node)
{
if (this.AvailableNodeCount == 0)
{
Debug.LogError("out index!");
}
if (this.AvailableENodes[node.Index] == null)
{
return;
}
this.ActiveENodes[node.Index] = node;
this.AvailableENodes[node.Index] = null;
this.AvailableNodeCount--;
}
19
Source : EffectLayer.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void RemoveActiveNode(EffectNode node)
{
if (this.AvailableNodeCount == this.MaxENodes)
{
Debug.LogError("out index!");
}
if (this.ActiveENodes[node.Index] == null)
{
return;
}
this.ActiveENodes[node.Index] = null;
this.AvailableENodes[node.Index] = node;
this.AvailableNodeCount++;
}
19
Source : RibbonTrail.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void UpdateIndices()
{
if (!this.IndexDirty)
{
return;
}
VertexPool pool = this.Vertexsegment.Pool;
if (this.Head != 99999 && this.Head != this.Tail)
{
int num = this.Head;
int num2 = 0;
for (; ; )
{
int num3 = num + 1;
if (num3 == this.MaxElements)
{
num3 = 0;
}
if (num3 * 2 >= 65536)
{
Debug.LogError("Too many elements!");
}
int num4 = this.Vertexsegment.VertStart + num3 * 2;
int num5 = this.Vertexsegment.VertStart + num * 2;
int num6 = this.Vertexsegment.IndexStart + num2 * 6;
pool.Indices[num6] = num5;
pool.Indices[num6 + 1] = num5 + 1;
pool.Indices[num6 + 2] = num4;
pool.Indices[num6 + 3] = num5 + 1;
pool.Indices[num6 + 4] = num4 + 1;
pool.Indices[num6 + 5] = num4;
if (num3 == this.Tail)
{
break;
}
num = num3;
num2++;
}
pool.IndiceChanged = true;
}
this.IndexDirty = false;
}
19
Source : RibbonTrail.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public void UpdateVertices(Vector3 eyePos)
{
float num = 0f;
float num2 = this.ElemLength * (float)(this.MaxElements - 2);
if (this.Head != 99999 && this.Head != this.Tail)
{
int num3 = this.Head;
int num4 = this.Head;
for (; ; )
{
if (num4 == this.MaxElements)
{
num4 = 0;
}
RibbonTrail.Element element = this.ElementArray[num4];
if (num4 * 2 >= 65536)
{
Debug.LogError("Too many elements!");
}
int num5 = this.Vertexsegment.VertStart + num4 * 2;
int num6 = num4 + 1;
if (num6 == this.MaxElements)
{
num6 = 0;
}
Vector3 lhs;
if (num4 == this.Head)
{
lhs = this.ElementArray[num6].Position - element.Position;
}
else if (num4 == this.Tail)
{
lhs = element.Position - this.ElementArray[num3].Position;
}
else
{
lhs = this.ElementArray[num6].Position - this.ElementArray[num3].Position;
}
Vector3 rhs = eyePos - element.Position;
Vector3 vector = Vector3.Cross(lhs, rhs);
vector.Normalize();
vector *= element.Width * 0.5f;
Vector3 vector2 = element.Position - vector;
Vector3 vector3 = element.Position + vector;
VertexPool pool = this.Vertexsegment.Pool;
float num7;
if (this.StretchType == 0)
{
num7 = num / num2 * Mathf.Abs(this.UVDimensions.y);
}
else
{
num7 = num / num2 * Mathf.Abs(this.UVDimensions.x);
}
Vector2 zero = Vectors.v2zero;
pool.Vertices[num5] = vector2;
pool.Colors[num5] = this.Color;
if (this.StretchType == 0)
{
zero.x = this.LowerLeftUV.x + this.UVDimensions.x;
zero.y = this.LowerLeftUV.y - num7;
}
else
{
zero.x = this.LowerLeftUV.x + num7;
zero.y = this.LowerLeftUV.y;
}
pool.UVs[num5] = zero;
pool.Vertices[num5 + 1] = vector3;
pool.Colors[num5 + 1] = this.Color;
if (this.StretchType == 0)
{
zero.x = this.LowerLeftUV.x;
zero.y = this.LowerLeftUV.y - num7;
}
else
{
zero.x = this.LowerLeftUV.x + num7;
zero.y = this.LowerLeftUV.y - Mathf.Abs(this.UVDimensions.y);
}
pool.UVs[num5 + 1] = zero;
if (num4 == this.Tail)
{
break;
}
num3 = num4;
num += (this.ElementArray[num6].Position - element.Position).magnitude;
num4++;
}
this.Vertexsegment.Pool.UVChanged = true;
this.Vertexsegment.Pool.VertChanged = true;
this.Vertexsegment.Pool.ColorChanged = true;
}
}
See More Examples