Here are the examples of the csharp api UnityEngine.Debug.LogWarning(object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
753 Examples
19
View Source File : PostEffectsBase.cs
License : Apache License 2.0
Project Creator : activey
License : Apache License 2.0
Project Creator : activey
public virtual bool CheckResources ()
{
Debug.LogWarning ("CheckResources () for " + ToString() + " should be overwritten.");
return isSupported;
}
19
View Source File : PostEffectsBase.cs
License : Apache License 2.0
Project Creator : activey
License : Apache License 2.0
Project Creator : activey
protected void ReportAutoDisable ()
{
Debug.LogWarning ("The image effect " + ToString() + " has been disabled as it's not supported on the current platform.");
}
19
View Source File : ColorCorrectionLookup.cs
License : Apache License 2.0
Project Creator : activey
License : Apache License 2.0
Project Creator : 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
View Source File : EquipItems.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
private void Start()
{
if (this.itemIDs != null && this.itemIDs.Length > 0)
{
InvEquipment invEquipment = base.GetComponent<InvEquipment>();
if (invEquipment == null)
{
invEquipment = base.gameObject.AddComponent<InvEquipment>();
}
int max = 12;
int i = 0;
int num = this.itemIDs.Length;
while (i < num)
{
int num2 = this.itemIDs[i];
InvBaseItem invBaseItem = InvDatabase.FindByID(num2);
if (invBaseItem != null)
{
invEquipment.Equip(new InvGameItem(num2, invBaseItem)
{
quality = (InvGameItem.Quality)UnityEngine.Random.Range(0, max),
itemLevel = NGUITools.RandomRange(invBaseItem.minItemLevel, invBaseItem.maxItemLevel)
});
}
else
{
Debug.LogWarning("Can't resolve the item ID of " + num2);
}
i++;
}
}
UnityEngine.Object.Destroy(this);
}
19
View Source File : ConnectAndJoinRandom.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public virtual void OnConnectedToMaster()
{
if (PhotonNetwork.networkingPeer.AvailableRegions != null)
{
Debug.LogWarning(string.Concat(new object[]
{
"List of available regions counts ",
PhotonNetwork.networkingPeer.AvailableRegions.Count,
". First: ",
PhotonNetwork.networkingPeer.AvailableRegions[0],
" \t Current Region: ",
PhotonNetwork.networkingPeer.CloudRegion
}));
}
Debug.Log("OnConnectedToMaster() was called by PUN. Now this client is connected and could join a room. Calling: PhotonNetwork.JoinRandomRoom();");
PhotonNetwork.JoinRandomRoom();
}
19
View Source File : PhotonHandler.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : 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
View Source File : PhotonNetwork.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
internal static void RPC(PhotonView view, string methodName, PhotonTargets target, params object[] parameters)
{
if (!VerifyCreplacedeNetwork())
{
return;
}
if (room == null)
{
Debug.LogWarning("Cannot send RPCs in Lobby! RPC dropped.");
return;
}
if (networkingPeer != null)
{
networkingPeer.RPC(view, methodName, target, parameters);
}
else
{
Debug.LogWarning("Could not execute RPC " + methodName + ". Possible scene loading in progress?");
}
}
19
View Source File : PhotonNetwork.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : 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
View Source File : PhotonNetwork.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
internal static void RPC(PhotonView view, string methodName, PhotonPlayer[] targets, params object[] parameters)
{
if (!VerifyCreplacedeNetwork())
{
return;
}
if (room == null)
{
Debug.LogWarning("Cannot send RPCs in Lobby! RPC dropped.");
return;
}
if (networkingPeer != null)
{
networkingPeer.RPC(view, methodName, targets, parameters);
}
else
{
Debug.LogWarning("Could not execute RPC " + methodName + ". Possible scene loading in progress?");
}
}
19
View Source File : PhotonNetwork.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static bool ConnectToMaster(string masterServerAddress, int port, string appID, string gameVersion)
{
string url = string.Empty;
if (networkingPeer.TransportProtocol >= ConnectionProtocol.WebSocket)
{
url = "ws";
if (networkingPeer.UsedProtocol == ConnectionProtocol.WebSocketSecure)
{
url += "s";
}
url += "://";
}
masterServerAddress = url + masterServerAddress;
if (networkingPeer.PeerState != PeerStateValue.Disconnected)
{
Debug.LogWarning("ConnectToMaster() failed. Can only connect while in state 'Disconnected'. Current state: " + networkingPeer.PeerState);
return false;
}
if (offlineMode)
{
offlineMode = false;
Debug.LogWarning("ConnectToMaster() disabled the offline mode. No longer offline.");
}
if (!isMessageQueueRunning)
{
isMessageQueueRunning = true;
Debug.LogWarning("ConnectToMaster() enabled isMessageQueueRunning. Needs to be able to dispatch incoming messages.");
}
networkingPeer.SetApp(appID, gameVersion);
networkingPeer.IsUsingNameServer = false;
networkingPeer.IsInitialConnect = true;
networkingPeer.MasterServerAddress = masterServerAddress + ":" + port;
return networkingPeer.Connect(networkingPeer.MasterServerAddress, ServerConnection.MasterServer);
}
19
View Source File : PhotonNetwork.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : 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
View Source File : PhotonNetwork.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static bool RaiseEvent(byte eventCode, object eventContent, bool sendReliable, RaiseEventOptions options)
{
if (!inRoom || eventCode >= 200)
{
Debug.LogWarning("RaiseEvent() failed. Your event is not being sent! Check if your are in a Room and the eventCode must be less than 200 (0..199).");
return false;
}
return networkingPeer.OpRaiseEvent(eventCode, eventContent, sendReliable, options);
}
19
View Source File : PhotonNetwork.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void UnAllocateViewID(int viewID)
{
manuallyAllocatedViewIds.Remove(viewID);
if (NetworkingPeer.photonViewList.ContainsKey(viewID))
{
Debug.LogWarning(string.Format("Unallocated manually used viewID: {0} but found it used still in a PhotonView: {1}", viewID, NetworkingPeer.photonViewList[viewID]));
}
}
19
View Source File : PhotonView.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
private void OnDisable()
{
if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer)
{
if (!this.destroyedByPhotonNetworkOrQuit)
{
PhotonNetwork.networkingPeer.LocalCleanPhotonView(this);
}
if (!this.destroyedByPhotonNetworkOrQuit && !Application.isLoadingLevel)
{
if (this.instantiationId > 0)
{
Debug.LogError(string.Concat(new object[]
{
"OnDestroy() seems to be called without PhotonNetwork.Destroy()?! GameObject: ",
base.gameObject,
" Application.isLoadingLevel: ",
Application.isLoadingLevel
}));
}
else if (this.viewID <= 0)
{
Debug.LogWarning(string.Format("OnDestroy manually allocated PhotonView {0}. The viewID is 0. Was it ever (manually) set?", this));
}
else if (this.IsMine && !PhotonNetwork.manuallyAllocatedViewIds.Contains(this.viewID))
{
Debug.LogWarning(string.Format("OnDestroy manually allocated PhotonView {0}. The viewID is local (isMine) but not in manuallyAllocatedViewIds list. Use UnAllocateViewID() after you destroyed the PV.", this));
}
}
if (PhotonNetwork.networkingPeer.instantiatedObjects.ContainsKey(this.instantiationId))
{
GameObject x = PhotonNetwork.networkingPeer.instantiatedObjects[this.instantiationId];
bool flag = x == base.gameObject;
if (flag)
{
Debug.LogWarning(string.Format("OnDestroy for PhotonView {0} but GO is still in instantiatedObjects. instantiationId: {1}. Use PhotonNetwork.Destroy(). {2} Identical with this: {3} PN.Destroyed called for this PV: {4}", new object[]
{
this,
this.instantiationId,
(!Application.isLoadingLevel) ? string.Empty : "Loading new scene caused this.",
flag,
this.destroyedByPhotonNetworkOrQuit
}));
}
}
didAwake = false;
}
}
19
View Source File : PhotonView.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
internal void OnDestroy()
{
if (!this.destroyedByPhotonNetworkOrQuit)
{
PhotonNetwork.networkingPeer.LocalCleanPhotonView(this);
}
if (!this.destroyedByPhotonNetworkOrQuit && !Application.isLoadingLevel)
{
if (this.instantiationId > 0)
{
Debug.LogError(string.Concat(new object[]
{
"OnDestroy() seems to be called without PhotonNetwork.Destroy()?! GameObject: ",
base.gameObject,
" Application.isLoadingLevel: ",
Application.isLoadingLevel
}));
}
else if (this.viewID <= 0)
{
Debug.LogWarning(string.Format("OnDestroy manually allocated PhotonView {0}. The viewID is 0. Was it ever (manually) set?", this));
}
else if (this.IsMine && !PhotonNetwork.manuallyAllocatedViewIds.Contains(this.viewID))
{
Debug.LogWarning(string.Format("OnDestroy manually allocated PhotonView {0}. The viewID is local (isMine) but not in manuallyAllocatedViewIds list. Use UnAllocateViewID() after you destroyed the PV.", this));
}
}
if (PhotonNetwork.networkingPeer.instantiatedObjects.ContainsKey(this.instantiationId))
{
GameObject x = PhotonNetwork.networkingPeer.instantiatedObjects[this.instantiationId];
bool flag = x == base.gameObject;
if (flag)
{
Debug.LogWarning(string.Format("OnDestroy for PhotonView {0} but GO is still in instantiatedObjects. instantiationId: {1}. Use PhotonNetwork.Destroy(). {2} Identical with this: {3} PN.Destroyed called for this PV: {4}", new object[]
{
this,
this.instantiationId,
(!Application.isLoadingLevel) ? string.Empty : "Loading new scene caused this.",
flag,
this.destroyedByPhotonNetworkOrQuit
}));
}
}
}
19
View Source File : PickupItemSyncer.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
private void SendPickedUpItems(PhotonPlayer targtePlayer)
{
if (targtePlayer == null)
{
Debug.LogWarning("Cant send PickupItem spawn times to unknown targetPlayer.");
return;
}
double time = PhotonNetwork.time;
double num = time + 0.20000000298023224;
PickupItem[] array = new PickupItem[PickupItem.DisabledPickupItems.Count];
PickupItem.DisabledPickupItems.CopyTo(array);
List<float> list = new List<float>(array.Length * 2);
foreach (PickupItem pickupItem in array)
{
if (pickupItem.SecondsBeforeRespawn <= 0f)
{
list.Add((float)pickupItem.ViewID);
list.Add(0f);
}
else
{
double num2 = pickupItem.TimeOfRespawn - PhotonNetwork.time;
if (pickupItem.TimeOfRespawn > num)
{
Debug.Log(string.Concat(new object[]
{
pickupItem.ViewID,
" respawn: ",
pickupItem.TimeOfRespawn,
" timeUntilRespawn: ",
num2,
" (now: ",
PhotonNetwork.time,
")"
}));
list.Add((float)pickupItem.ViewID);
list.Add((float)num2);
}
}
}
Debug.Log(string.Concat(new object[]
{
"Sent count: ",
list.Count,
" now: ",
time
}));
BasePV.RPC("PickupItemInit", targtePlayer, new object[]
{
PhotonNetwork.time,
list.ToArray()
});
}
19
View Source File : ShowInfoOfPlayer.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
private void Start()
{
if (this.font == null)
{
this.font = (Font)Resources.FindObjectsOfTypeAll(typeof(Font))[0];
Debug.LogWarning("No font defined. Found font: " + this.font);
}
if (this.tm == null)
{
this.textGo = new GameObject("3d text");
this.textGo.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
this.textGo.transform.parent = base.gameObject.transform;
this.textGo.transform.localPosition = Vectors.zero;
MeshRenderer meshRenderer = this.textGo.AddComponent<MeshRenderer>();
meshRenderer.material = this.font.material;
this.tm = this.textGo.AddComponent<TextMesh>();
this.tm.font = this.font;
this.tm.fontSize = 0;
this.tm.anchor = TextAnchor.MiddleCenter;
}
if (!this.DisableOnOwnObjects && BasePV.IsMine)
{
base.enabled = false;
}
}
19
View Source File : SmoothSyncMovement.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public void Awake()
{
if (BasePV == null || BasePV.observed != this)
{
Debug.LogWarning(this + " is not observed by this object's photonView! OnPhotonSerializeView() in this clreplaced won't be used.");
}
if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
{
enabled = false;
}
baseT = transform;
correctPlayerPos = baseT.position;
correctPlayerRot = baseT.rotation;
if (rigidbody != null)
{
noVelocity = false;
baseR = rigidbody;
correctPlayerVelocity = baseR.velocity;
}
}
19
View Source File : SmoothSyncMovement2.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public void Awake()
{
if (BasePV == null || BasePV.observed != this)
{
Debug.LogWarning(this + " is not observed by this object's photonView! OnPhotonSerializeView() in this clreplaced won't be used.");
return;
}
if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
{
enabled = false;
return;
}
baseT = transform;
correctPlayerPos = baseT.position;
correctPlayerRot = baseT.rotation;
}
19
View Source File : SmoothSyncMovement3.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public void Awake()
{
if (BasePV == null || BasePV.observed != this)
{
Debug.LogWarning(this + " is not observed by this object's photonView! OnPhotonSerializeView() in this clreplaced won't be used.");
}
if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
{
base.enabled = false;
}
baseT = transform;
correctPlayerPos = baseT.position;
correctPlayerRot = baseT.rotation;
}
19
View Source File : Minimap.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
private void CreateMinimapRT(Camera cam, int pixelSize)
{
if (minimapRT == null)
{
bool flag2 = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RGB565);
int num = flag2 ? 4 : 7;
this.minimapRT = new RenderTexture(pixelSize, pixelSize, 16, RenderTextureFormat.RGB565);
if (!flag2)
{
Debug.LogWarning(SystemInfo.graphicsDeviceName + " (" + SystemInfo.graphicsDeviceVendor + ") does not support RGB565 format, the minimap will have transparency issues on certain maps");
}
}
cam.targetTexture = this.minimapRT;
}
19
View Source File : AssetBundleFilesAnalyze.cs
License : MIT License
Project Creator : akof1314
License : MIT License
Project Creator : akof1314
private static List<replacedetBundleFileInfo> replacedyzeManifestDepend(string directoryPath)
{
string manifestName = Path.GetFileName(directoryPath);
string manifestPath = Path.Combine(directoryPath, manifestName);
if (!File.Exists(manifestPath))
{
Debug.LogWarning(manifestPath + " is not exists! Use replacedyzAllFiles ...");
return null;
}
#if UNITY_5_3_OR_NEWER
replacedetBundle manifestAb = replacedetBundle.LoadFromFile(manifestPath);
#else
replacedetBundle manifestAb = replacedetBundle.CreateFromMemoryImmediate(File.ReadAllBytes(manifestPath));
#endif
if (!manifestAb)
{
Debug.LogError(manifestPath + " ab load faild!");
return null;
}
List<replacedetBundleFileInfo> infos = new List<replacedetBundleFileInfo>();
#if UNITY_5 || UNITY_5_3_OR_NEWER
replacedetBundleManifest replacedetBundleManifest = manifestAb.Loadreplacedet<replacedetBundleManifest>("replacedetbundlemanifest");
var bundles = replacedetBundleManifest.GetAllreplacedetBundles();
foreach (var bundle in bundles)
{
string path = Path.Combine(directoryPath, bundle);
replacedetBundleFileInfo info = new replacedetBundleFileInfo
{
name = bundle,
path = path,
rootPath = directoryPath,
size = new FileInfo(path).Length,
directDepends = replacedetBundleManifest.GetDirectDependencies(bundle),
allDepends = replacedetBundleManifest.GetAllDependencies(bundle)
};
infos.Add(info);
}
#endif
manifestAb.Unload(true);
return infos;
}
19
View Source File : NewBehaviourScript.cs
License : MIT License
Project Creator : akof1314
License : MIT License
Project Creator : akof1314
[ContextMenu("test")]
public void Test()
{
Debug.Log("abcabc");
Debug.Log("a222bcabc");
Debug.Log("abcabc");
Debug.LogError("Opens replacedet in an external editor, \ntexture application or modelling tool depending on what type of replacedet it is. \nIf it is a text file, lineNumber instructs the text editor to go to that line. Returns true if replacedet opened successfully.");
Debug.Log("abcabc");
Debug.LogWarning("Description");
Test1("aaaa11");
}
19
View Source File : NewBehaviourScript.cs
License : MIT License
Project Creator : akof1314
License : MIT License
Project Creator : akof1314
private void Test3()
{
for (int i = 0; i < 9999; i++)
{
Debug.LogError("A variant of Debug.Log that logs an error message to the console.");
Debug.Log("replacedert a condition and logs an error message to the Unity console on failure");
Debug.LogWarning("Clreplaced containing methods to ease debugging while developing a game");
}
}
19
View Source File : NewBehaviourScript.cs
License : MIT License
Project Creator : akof1314
License : MIT License
Project Creator : akof1314
[ContextMenu("test")]
public void Test()
{
Debug.Log("abcabc");
Debug.Log("a222bcabc");
Debug.Log("abcabc");
Debug.LogError("Opens replacedet in an external editor, \ntexture application or modelling tool depending on what type of replacedet it is. \nIf it is a text file, lineNumber instructs the text editor to go to that line. Returns true if replacedet opened successfully.");
Debug.Log("abcabc");
Debug.LogWarning("Description");
Test1("aaaa1");
}
19
View Source File : MainThreadDispatcher.cs
License : MIT License
Project Creator : ArchonInteractive
License : MIT License
Project Creator : ArchonInteractive
public static void Enqueue(Action action)
{
EnsureInitialized();
if (IsMainThread)
Debug.LogWarning("Enqueue called from the main thread. Are you sure this is what you meant to do?");
lock (ActionQueue)
{
ActionQueue.Enqueue(action);
}
}
19
View Source File : AmplifyOcclusionEffect.cs
License : MIT License
Project Creator : BrunoS3D
License : MIT License
Project Creator : BrunoS3D
void Update()
{
if( m_targetCamera != null )
{
if( m_targetCamera.actualRenderingPath != RenderingPath.DeferredShading )
{
if( PerPixelNormals != PerPixelNormalSource.None && PerPixelNormals != PerPixelNormalSource.Camera )
{
m_paramsChanged = true;
PerPixelNormals = PerPixelNormalSource.Camera;
if( m_targetCamera.cameraType != UnityEngine.CameraType.SceneView )
{
UnityEngine.Debug.LogWarning( "[AmplifyOcclusion] GBuffer Normals only available in Camera Deferred Shading mode. Switched to Camera source." );
}
}
if( ApplyMethod == ApplicationMethod.Deferred )
{
m_paramsChanged = true;
ApplyMethod = ApplicationMethod.PostEffect;
if( m_targetCamera.cameraType != UnityEngine.CameraType.SceneView )
{
UnityEngine.Debug.LogWarning( "[AmplifyOcclusion] Deferred Method requires a Deferred Shading path. Switching to Post Effect Method." );
}
}
}
else
{
if( PerPixelNormals == PerPixelNormalSource.Camera )
{
m_paramsChanged = true;
PerPixelNormals = PerPixelNormalSource.GBuffer;
if( m_targetCamera.cameraType != UnityEngine.CameraType.SceneView )
{
UnityEngine.Debug.LogWarning( "[AmplifyOcclusion] Camera Normals not supported for Deferred Method. Switching to GBuffer Normals." );
}
}
}
if( ( m_targetCamera.depthTextureMode & DepthTextureMode.Depth ) == 0 )
{
m_targetCamera.depthTextureMode |= DepthTextureMode.Depth;
}
if( ( PerPixelNormals == PerPixelNormalSource.Camera ) &&
( m_targetCamera.depthTextureMode & DepthTextureMode.DepthNormals ) == 0 )
{
m_targetCamera.depthTextureMode |= DepthTextureMode.DepthNormals;
}
if( ( UsingMotionVectors == true ) &&
( m_targetCamera.depthTextureMode & DepthTextureMode.MotionVectors ) == 0 )
{
m_targetCamera.depthTextureMode |= DepthTextureMode.MotionVectors;
}
}
else
{
m_targetCamera = GetComponent<Camera>();
}
}
19
View Source File : FormatterLocator.cs
License : MIT License
Project Creator : BrunoS3D
License : MIT License
Project Creator : BrunoS3D
private static IFormatter CreateFormatter(Type type, ISerializationPolicy policy)
{
if (FormatterUtilities.IsPrimitiveType(type))
{
throw new ArgumentException("Cannot create formatters for a primitive type like " + type.Name);
}
// First call formatter locators before checking for registered formatters
for (int i = 0; i < FormatterLocators.Count; i++)
{
try
{
IFormatter result;
if (FormatterLocators[i].LocatorInstance.TryGetFormatter(type, FormatterLocationStep.BeforeRegisteredFormatters, policy, out result))
{
return result;
}
}
catch (TargetInvocationException ex)
{
throw ex;
}
catch (TypeInitializationException ex)
{
throw ex;
}
#pragma warning disable CS0618 // Type or member is obsolete
catch (ExecutionEngineException ex)
#pragma warning restore CS0618 // Type or member is obsolete
{
throw ex;
}
catch (Exception ex)
{
Debug.LogException(new Exception("Exception was thrown while calling FormatterLocator " + FormatterLocators[i].GetType().FullName + ".", ex));
}
}
// Then check for valid registered formatters
for (int i = 0; i < FormatterInfos.Count; i++)
{
var info = FormatterInfos[i];
Type formatterType = null;
if (type == info.TargetType)
{
formatterType = info.FormatterType;
}
else if (info.FormatterType.IsGenericType && info.TargetType.IsGenericParameter)
{
Type[] inferredArgs;
if (info.FormatterType.TryInferGenericParameters(out inferredArgs, type))
{
formatterType = info.FormatterType.GetGenericTypeDefinition().MakeGenericType(inferredArgs);
}
}
else if (type.IsGenericType && info.FormatterType.IsGenericType && info.TargetType.IsGenericType && type.GetGenericTypeDefinition() == info.TargetType.GetGenericTypeDefinition())
{
Type[] args = type.GetGenericArguments();
if (info.FormatterType.AreGenericConstraintsSatisfiedBy(args))
{
formatterType = info.FormatterType.GetGenericTypeDefinition().MakeGenericType(args);
}
}
if (formatterType != null)
{
var instance = GetFormatterInstance(formatterType);
if (instance == null) continue;
if (info.AskIfCanFormatTypes && !((IAskIfCanFormatTypes)instance).CanFormatType(type))
{
continue;
}
return instance;
}
}
// Then call formatter locators after checking for registered formatters
for (int i = 0; i < FormatterLocators.Count; i++)
{
try
{
IFormatter result;
if (FormatterLocators[i].LocatorInstance.TryGetFormatter(type, FormatterLocationStep.AfterRegisteredFormatters, policy, out result))
{
return result;
}
}
catch (TargetInvocationException ex)
{
throw ex;
}
catch (TypeInitializationException ex)
{
throw ex;
}
#pragma warning disable CS0618 // Type or member is obsolete
catch (ExecutionEngineException ex)
#pragma warning restore CS0618 // Type or member is obsolete
{
throw ex;
}
catch (Exception ex)
{
Debug.LogException(new Exception("Exception was thrown while calling FormatterLocator " + FormatterLocators[i].GetType().FullName + ".", ex));
}
}
// If we can, emit a formatter to handle serialization of this object
{
if (EmitUtilities.CanEmit)
{
var result = FormatterEmitter.GetEmittedFormatter(type, policy);
if (result != null) return result;
}
}
if (EmitUtilities.CanEmit)
{
Debug.LogWarning("Fallback to reflection for type " + type.Name + " when emit is possible on this platform.");
}
// Finally, we fall back to a reflection-based formatter if nothing else has been found
return (IFormatter)Activator.CreateInstance(typeof(ReflectionFormatter<>).MakeGenericType(type));
}
19
View Source File : AmplifyOcclusionEffect.cs
License : MIT License
Project Creator : BrunoS3D
License : MIT License
Project Creator : BrunoS3D
void OnEnable()
{
m_myID = m_nextID;
m_myIDstring = m_myID.ToString();
m_nextID++;
if( !checkRenderTextureFormats() )
{
Debug.LogError( "[AmplifyOcclusion] Target platform does not meet the minimum requirements for this effect to work properly." );
this.enabled = false;
return;
}
if( CacheAware == true )
{
if( SystemInfo.SupportsRenderTextureFormat( RenderTextureFormat.RFloat ) == false )
{
CacheAware = false;
UnityEngine.Debug.LogWarning( "[AmplifyOcclusion] System does not support RFloat RenderTextureFormat. CacheAware will be disabled." );
}
else
{
if( SystemInfo.copyTextureSupport == CopyTextureSupport.None )
{
CacheAware = false;
UnityEngine.Debug.LogWarning( "[AmplifyOcclusion] System does not support CopyTexture. CacheAware will be disabled." );
}
else
{
// AO-62 - some OpenGLES devices actually implement RFloat buffers using RHalf format.
if( ( SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLES2 ) ||
( SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLES3 ) )
{
CacheAware = false;
UnityEngine.Debug.LogWarningFormat( "[AmplifyOcclusion] CacheAware is not supported on {0} devices. CacheAware will be disabled.", SystemInfo.graphicsDeviceType );
}
}
}
}
checkMaterials( false );
createQuadMesh();
#if UNITY_2017_1_OR_NEWER
if( GraphicsSettings.HreplacedhaderDefine( Graphics.activeTier, BuiltinShaderDefine.SHADER_API_MOBILE ) )
{
// using 16376.0 for DepthScale for mobile due to precision issues
m_oneOverDepthScale = 1.0f / 16376.0f;
}
#else
#if UNITY_IPHONE || UNITY_ANDROID
m_oneOverDepthScale = 1.0f / 16376.0f;
#endif
#endif
}
19
View Source File : AmqpObjectListController.cs
License : MIT License
Project Creator : CymaticLabs
License : MIT License
Project Creator : CymaticLabs
void UpdateObject(JSONNode msg)
{
// Get the message ID filter, if any
var id = msg["id"] != null ? msg["id"].Value : null;
if (string.IsNullOrEmpty(id))
{
if (DebugLogMessages) Debug.LogWarning("AMQP message received without 'id' property.");
return;
}
// Get the object given its message ID
if (!objectsById.ContainsKey(id))
{
if (DebugLogMessages) Debug.LogWarningFormat("No AMQP Object Control Reference found for ID: {0}.", id);
return;
}
// Get the object reference for this ID
var objRef = objectsById[id];
if (UpdatePosition)
{
// If the property exists use its value, otherwise just use the current value
var objPos = UpdateInWorldSpace ? objRef.transform.position : objRef.transform.localPosition;
var posX = msg["posX"] != null ? msg["posX"].AsFloat : objPos.x;
var posY = msg["posY"] != null ? msg["posY"].AsFloat : objPos.y;
var posZ = msg["posZ"] != null ? msg["posZ"].AsFloat : objPos.z;
// Update with new values
if (UpdateInWorldSpace)
{
objRef.transform.position = new Vector3(posX, posY, posZ);
}
else
{
objRef.transform.localPosition = new Vector3(posX, posY, posZ);
}
}
if (UpdateRotation)
{
// If the property exists use its value, otherwise just use the current value
var objRot = UpdateInWorldSpace ? objRef.transform.eulerAngles : objRef.transform.localEulerAngles;
var rotX = msg["rotX"] != null ? msg["rotX"].AsFloat : objRot.x;
var rotY = msg["rotY"] != null ? msg["rotY"].AsFloat : objRot.y;
var rotZ = msg["rotZ"] != null ? msg["rotZ"].AsFloat : objRot.z;
// Update with new values
if (UpdateInWorldSpace)
{
objRef.transform.eulerAngles = new Vector3(rotX, rotY, rotZ);
}
else
{
objRef.transform.localEulerAngles = new Vector3(rotX, rotY, rotZ);
}
}
if (UpdateScale)
{
// If the property exists use its value, otherwise just use the current value
var scaleX = msg["sclX"] != null ? msg["sclX"].AsFloat : objRef.transform.localScale.x;
var scaleY = msg["sclY"] != null ? msg["sclY"].AsFloat : objRef.transform.localScale.y;
var scaleZ = msg["sclZ"] != null ? msg["sclZ"].AsFloat : objRef.transform.localScale.z;
// Update with new values
objRef.transform.localScale = new Vector3(scaleX, scaleY, scaleZ);
}
}
19
View Source File : ABModel.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
static internal void LogWarning(string message)
{
Debug.LogWarning("replacedetBundleBrowser: " + message);
}
19
View Source File : AssetBundleTree.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
void DedupeBundles(object context, bool onlyOverlappedreplacedets)
{
var selectedNodes = context as List<replacedetBundleModel.BundleTreeItem>;
var newBundle = replacedetBundleModel.Model.HandleDedupeBundles(selectedNodes.Select(item => item.bundle), onlyOverlappedreplacedets);
if(newBundle != null)
{
var selection = new List<int>();
selection.Add(newBundle.nameHashCode);
ReloadAndSelect(selection);
}
else
{
if (onlyOverlappedreplacedets)
Debug.LogWarning("There were no duplicated replacedets that existed across all selected bundles.");
else
Debug.LogWarning("No duplicate replacedets found after refreshing bundle contents.");
}
}
19
View Source File : Log.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public static void w(string message)
{
Debug.LogWarning(TAG + " " + message);
}
19
View Source File : HttpBase.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
private static void DebugLog(bool debugEnabled, object message, bool isError)
{
if (debugEnabled)
{
if (isError)
Debug.LogWarning(message);
else
Debug.Log(message);
}
}
19
View Source File : GraphyDebugger.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
private void ExecuteOperationsInDebugPacket(DebugPacket debugPacket)
{
if (debugPacket != null)
{
if (debugPacket.DebugBreak)
{
Debug.Break();
}
if (debugPacket.Message != "")
{
string message = "[Graphy] (" + System.DateTime.Now + "): " + debugPacket.Message;
switch (debugPacket.MessageType)
{
case MessageType.Log:
Debug.Log(message);
break;
case MessageType.Warning:
Debug.LogWarning(message);
break;
case MessageType.Error:
Debug.LogError(message);
break;
}
}
if (debugPacket.TakeScreenshot)
{
string path = debugPacket.ScreenshotFileName + "_" + System.DateTime.Now + ".png";
path = path.Replace("/", "-").Replace(" ", "_").Replace(":", "-");
#if UNITY_2017_1_OR_NEWER
ScreenCapture.CaptureScreenshot(path);
#else
Application.CaptureScreenshot(path);
#endif
}
debugPacket.UnityEvents.Invoke();
foreach (var callback in debugPacket.Callbacks)
{
if (callback != null) callback();
}
debugPacket.Executed();
}
}
19
View Source File : DebugLogConsole.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public static void ExecuteCommand( string command )
{
if( command == null )
return;
command = command.Trim();
if( command.Length == 0 )
return;
// Parse the arguments
commandArguments.Clear();
int endIndex = IndexOfChar( command, ' ', 0 );
commandArguments.Add( command.Substring( 0, endIndex ) );
for( int i = endIndex + 1; i < command.Length; i++ )
{
if( command[i] == ' ' )
continue;
int delimiterIndex = IndexOfDelimiter( command[i] );
if( delimiterIndex >= 0 )
{
endIndex = IndexOfChar( command, inputDelimiters[delimiterIndex][1], i + 1 );
commandArguments.Add( command.Substring( i + 1, endIndex - i - 1 ) );
}
else
{
endIndex = IndexOfChar( command, ' ', i + 1 );
commandArguments.Add( command.Substring( i, endIndex - i ) );
}
i = endIndex;
}
// Check if command exists
ConsoleMethodInfo methodInfo;
if( !methods.TryGetValue( commandArguments[0], out methodInfo ) )
Debug.LogWarning( "Can't find command: " + commandArguments[0] );
else if( !methodInfo.IsValid() )
Debug.LogWarning( "Method no longer valid (instance dead): " + commandArguments[0] );
else
{
// Check if number of parameter match
if( methodInfo.parameterTypes.Length != commandArguments.Count - 1 )
{
Debug.LogWarning( "Parameter count mismatch: " + methodInfo.parameterTypes.Length + " parameters are needed" );
return;
}
Debug.Log( "Executing command: " + commandArguments[0] );
// Parse the parameters into objects
object[] parameters = new object[methodInfo.parameterTypes.Length];
for( int i = 0; i < methodInfo.parameterTypes.Length; i++ )
{
string argument = commandArguments[i + 1];
Type parameterType = methodInfo.parameterTypes[i];
if( typeof( Component ).IsreplacedignableFrom( parameterType ) )
{
UnityEngine.Object val = argument == "null" ? null : GameObject.Find( argument );
if( val )
val = ( (GameObject) val ).GetComponent( parameterType );
parameters[i] = val;
}
else
{
ParseFunction parseFunction;
if( !parseFunctions.TryGetValue( parameterType, out parseFunction ) )
{
Debug.LogError( "Unsupported parameter type: " + parameterType.Name );
return;
}
object val;
if( !parseFunction( argument, out val ) )
{
Debug.LogError( "Couldn't parse " + argument + " to " + parameterType.Name );
return;
}
parameters[i] = val;
}
}
// Execute the method replacedociated with the command
object result = methodInfo.method.Invoke( methodInfo.instance, parameters );
if( methodInfo.method.ReturnType != typeof( void ) )
{
// Print the returned value to the console
if( result == null || result.Equals( null ) )
Debug.Log( "Value returned: null" );
else
Debug.Log( "Value returned: " + result.ToString() );
}
}
}
19
View Source File : NativeShare.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public void Share()
{
if( files.Count == 0 && subject.Length == 0 && text.Length == 0 )
{
Debug.LogWarning( "Share Error: attempting to share nothing!" );
return;
}
#if UNITY_EDITOR
Debug.Log( "Shared!" );
#elif UNITY_ANDROID
AJC.CallStatic( "Share", Context, targetPackage, targetClreplaced, files.ToArray(), mimes.ToArray(), subject, text, replacedle );
#elif UNITY_IOS
_NativeShare_Share( files.ToArray(), files.Count, subject, text );
#else
Debug.Log( "No sharing set up for this platform." );
#endif
}
19
View Source File : MainThreadDispatcher.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
void Awake()
{
if (instance == null)
{
instance = this;
mainThreadToken = new object();
initialized = true;
updateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex));
fixedUpdateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex));
endOfFrameMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex));
StartCoroutine(RunUpdateMicroCoroutine());
StartCoroutine(RunFixedUpdateMicroCoroutine());
StartCoroutine(RunEndOfFrameMicroCoroutine());
DontDestroyOnLoad(gameObject);
}
else
{
if (this != instance)
{
if (cullingMode == CullingMode.Self)
{
// Try to destroy this dispatcher if there's already one in the scene.
Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Removing myself...");
DestroyDispatcher(this);
}
else if (cullingMode == CullingMode.All)
{
Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Cleaning up all excess dispatchers...");
CullAllExcessDispatchers();
}
else
{
Debug.LogWarning("There is already a MainThreadDispatcher in the scene.");
}
}
}
}
19
View Source File : DetectHeadset.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public static bool Detect() {
try
{
#if UNITY_IOS && !UNITY_EDITOR
return _Detect();
#elif UNITY_ANDROID && !UNITY_EDITOR
using (var javaUnityPlayer = new AndroidJavaClreplaced("com.unity3d.player.UnityPlayer")) {
using (var currentActivity = javaUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) {
using (var androidPlugin =
new AndroidJavaObject("me.tigerhix.cytoid.DetectHeadset", currentActivity)) {
return androidPlugin.Call<bool>("_Detect");
}
}
}
#else
return false;
#endif
}
catch (Exception e)
{
Debug.LogWarning("Could not detect headset");
Debug.LogWarning(e);
return false;
}
}
19
View Source File : CharacterManager.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public async UniTask<Characterreplacedet> SetActiveCharacter(string id, bool requiresReload = true)
{
if (id == null) throw new ArgumentNullException();
var bundleId = "character_" + id.ToLower();
if (ActiveCharacterBundleId == bundleId) return activeCharacterGameObject.GetComponent<Characterreplacedet>();
if (!Context.BundleManager.IsCached(bundleId))
{
Debug.LogWarning($"Character {bundleId} is not cached");
return null;
}
var characterBundle = await Context.BundleManager.LoadCachedBundle(bundleId);
if (characterBundle == null)
{
Debug.LogWarning($"Downloaded replacedet {bundleId} does not exist");
return null;
}
if (activeCharacterreplacedetBundle != null && requiresReload)
{
// Delay the release to allow LoopAudioPlayer to transition between character songs
var currentGameObject = activeCharacterGameObject;
var currentBundleId = ActiveCharacterBundleId;
Run.After(2.0f, () =>
{
UnityEngine.Object.Destroy(currentGameObject);
Context.BundleManager.Release(currentBundleId);
});
}
activeCharacterreplacedetBundle = characterBundle;
SelectedCharacterId = id;
ActiveCharacterBundleId = bundleId;
// Instantiate the GameObject
var loader = activeCharacterreplacedetBundle.LoadreplacedetAsync<GameObject>("Character");
await loader;
activeCharacterGameObject = UnityEngine.Object.Instantiate((GameObject) loader.replacedet);
var characterreplacedet = activeCharacterGameObject.GetComponent<Characterreplacedet>();
OnActiveCharacterSet.Invoke(characterreplacedet, requiresReload);
useTestCharacterreplacedet = false;
return characterreplacedet;
}
19
View Source File : CharacterManager.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public async UniTask<(string, CharacterMeta.ExpData)> FetchSelectedCharacterExp(bool useLocal = false)
{
var characterMeta = Context.Database.Let(it =>
{
var col = it.GetCollection<CharacterMeta>("characters");
try
{
var result = col.Find(m => m.replacedetId == Context.CharacterManager.SelectedCharacterId);
return result.FirstOrDefault();
}
catch (Exception e)
{
Debug.LogWarning(e);
return null;
}
});
if (characterMeta != null)
{
if (useLocal || Context.IsOffline())
{
return (characterMeta.Name, characterMeta.Exp);
}
// Fetch latest exp
bool? success = null;
var name = characterMeta.Name;
CharacterMeta.ExpData exp = null;
RestClient.Get<CharacterMeta.ExpData>(new RequestHelper
{
Uri = $"{Context.ApiUrl}/characters/{characterMeta.Id}/exp",
Headers = Context.OnlinePlayer.GetRequestHeaders(),
EnableDebug = true
}).Then(data =>
{
success = true;
name = characterMeta.Name;
exp = data;
// Update DB meta
Context.Database.Let(it =>
{
var col = it.GetCollection<CharacterMeta>("characters");
var localMeta = col.FindOne(meta => meta.Id == characterMeta.Id);
localMeta.Exp = data;
col.Update(localMeta);
});
}).Catch(err =>
{
success = false;
Debug.LogError(err);
});
await UniTask.WaitUntil(() => success != null);
return (name, exp);
}
return (null, null);
}
19
View Source File : GameState.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public void Judge(Note note, NoteGrade grade, double error, double greatGradeWeight)
{
if (IsCompleted || IsFailed)
{
return;
}
if (Judgements[note.Model.id].IsJudged)
{
return;
Debug.LogWarning($"Trying to judge note {note.Model.id} which is already judged.");
}
ClearCount++;
Judgements[note.Model.id].Apply(it =>
{
it.IsJudged = true;
it.Grade = grade;
it.Error = error;
});
if (Mode == GameMode.Practice)
{
if (grade != NoteGrade.Perfect && grade != NoteGrade.Great) isFullScorePossible = false;
}
else
{
if (grade != NoteGrade.Perfect) isFullScorePossible = false;
}
// Combo
var miss = grade == NoteGrade.Bad || grade == NoteGrade.Miss;
if (miss) Combo = 0;
else Combo++;
if (Combo > MaxCombo) MaxCombo = Combo;
if (Mode == GameMode.Tier)
{
if (miss) Context.TierState.Combo = 0;
else Context.TierState.Combo++;
if (Context.TierState.Combo > Context.TierState.MaxCombo)
Context.TierState.MaxCombo = Context.TierState.Combo;
}
// Score multiplier
if (Mode != GameMode.Practice)
{
switch (grade)
{
case NoteGrade.Perfect:
NoteScoreMultiplier += 0.004D * noteScoreMultiplierFactor;
break;
case NoteGrade.Great:
NoteScoreMultiplier += 0.002D * noteScoreMultiplierFactor;
break;
case NoteGrade.Good:
NoteScoreMultiplier += 0.001D * noteScoreMultiplierFactor;
break;
case NoteGrade.Bad:
NoteScoreMultiplier -= 0.025D * noteScoreMultiplierFactor;
break;
case NoteGrade.Miss:
NoteScoreMultiplier -= 0.05D * noteScoreMultiplierFactor;
break;
}
if (NoteScoreMultiplier > 1) NoteScoreMultiplier = 1;
if (NoteScoreMultiplier < 0) NoteScoreMultiplier = 0;
}
// Score
if (Mode == GameMode.Practice)
{
Score += 900000.0 / NoteCount * grade.GetScoreWeight(false) +
100000.0 / (NoteCount * (NoteCount + 1) / 2.0) * Combo;
}
else
{
var maxNoteScore = 1000000.0 / NoteCount;
double noteScore;
if (grade == NoteGrade.Great)
{
noteScore = maxNoteScore * (NoteGrade.Great.GetScoreWeight(true) +
(NoteGrade.Perfect.GetScoreWeight(true) -
NoteGrade.Great.GetScoreWeight(true)) *
greatGradeWeight);
}
else
{
noteScore = maxNoteScore * grade.GetScoreWeight(true);
}
noteScore *= NoteScoreMultiplier;
Score += noteScore;
}
if (Score > 999500)
{
if (ClearCount == NoteCount && isFullScorePossible)
{
Score = 1000000;
}
}
if (Score > 1000000) Score = 1000000;
if (Score == 1000000 && !isFullScorePossible) Score = 999999; // In case of double inaccuracy
// Accuracy
if (Mode == GameMode.Practice || grade != NoteGrade.Great)
{
acreplacedulatedAccuracy += 1.0 * grade.GetAccuracyWeight();
}
else
{
acreplacedulatedAccuracy += 1.0 * (NoteGrade.Great.GetAccuracyWeight() +
(NoteGrade.Perfect.GetAccuracyWeight() -
NoteGrade.Great.GetAccuracyWeight()) *
greatGradeWeight);
}
Accuracy = acreplacedulatedAccuracy / ClearCount;
// Health mods
if (UseHealthSystem)
{
var mods = Mods.Contains(Mod.ExHard) ? exHardHpMods : hardHpMods;
if (Mode == GameMode.Tier) mods = tierHpMods;
var mod = mods
.Select[note.Type]
.Select[Mode == GameMode.Practice ? unrankedGradingIndex[grade] : rankedGradingIndex[grade]];
double change = 0;
switch (mod.Type)
{
case HpModType.Absolute:
change = mod.Value;
break;
case HpModType.Percentage:
change = mod.Value / 100f * MaxHealth;
break;
case HpModType.DivideByNoteCount:
change = mod.Value / NoteCount / 100f * MaxHealth;
break;
}
if (change < 0 && mod.UseHealthBuffer)
{
double a;
if (HealthPercentage > 0.3) a = 1;
else a = 0.25 + 2.5 * HealthPercentage;
change *= a;
}
Health += change;
Health = Math.Min(Math.Max(Health, 0), MaxHealth);
if (Health <= 0) ShouldFail = true;
if (Mode == GameMode.Tier)
{
Context.TierState.Health = Health;
}
}
if (
Mods.Contains(Mod.AP) && grade != NoteGrade.Perfect
||
Mods.Contains(Mod.FC) && (grade == NoteGrade.Bad || grade == NoteGrade.Miss)
)
{
ShouldFail = true;
}
}
19
View Source File : CollectionCard.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public async void LoadCover()
{
if (loadedCover && cover.sprite != null && cover.sprite.texture != null)
{
// If sprite was loaded and the texture is not destroyed
return;
}
loadedCover = false;
cover.DOKill();
cover.SetAlpha(0);
if (coverToken != null)
{
if (!coverToken.IsCancellationRequested) coverToken.Cancel();
coverToken = null;
}
if (DoNotLoadCover)
{
coverToken = new CancellationTokenSource();
try
{
await UniTask.WaitUntil(() => !DoNotLoadCover, cancellationToken: coverToken.Token);
}
catch
{
return;
}
}
if (!((RectTransform) transform).IsVisible())
{
coverToken = new CancellationTokenSource();
try
{
await UniTask.WaitUntil(() => ((RectTransform) transform).IsVisible(),
cancellationToken: coverToken.Token);
await UniTask.DelayFrame(0);
}
catch
{
return;
}
}
coverToken = new CancellationTokenSource();
Sprite sprite = null;
try
{
try
{
var path = collection.cover.ThumbnailUrl;
sprite = await Context.replacedetMemory.Loadreplacedet<Sprite>(path, replacedetTag.CollectionCoverThumbnail,
coverToken.Token,
new SpritereplacedetOptions(new[] {Context.CollectionThumbnailWidth, Context.CollectionThumbnailHeight}));
}
catch
{
return;
}
}
catch (Exception e)
{
Debug.LogWarning(e);
if (sprite != null)
{
// Should be impossible
Destroy(sprite.texture);
Destroy(sprite);
}
return;
}
if (sprite != null)
{
lock (sprite)
{
if (sprite != null)
{
if (cover == null) return;
cover.sprite = sprite;
cover.DOFade(0.15f, 0.2f);
cover.FitSpriteAspectRatio();
loadedCover = true;
}
}
}
coverToken = null;
}
19
View Source File : LevelCard.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public async void LoadCover()
{
if (loadedCover && cover.sprite != null && cover.sprite.texture != null) return;
cover.DOKill();
cover.SetAlpha(0);
if (coverToken != null)
{
if (!coverToken.IsCancellationRequested) coverToken.Cancel();
coverToken = null;
}
/*if (DoNotLoadCover)
{
coverToken = new CancellationTokenSource();
try
{
await UniTask.WaitUntil(() => !DoNotLoadCover, cancellationToken: coverToken.Token);
}
catch
{
return;
}
}*/
if (!((RectTransform) transform).IsVisible())
{
coverToken = new CancellationTokenSource();
try
{
await UniTask.WaitUntil(() => this == null || transform == null || ((RectTransform) transform).IsVisible(), cancellationToken: coverToken.Token);
}
catch (OperationCanceledException)
{
return;
}
if (this == null || transform == null) return;
}
coverToken = new CancellationTokenSource();
try
{
await UniTask.DelayFrame(0, cancellationToken: coverToken.Token);
}
catch (OperationCanceledException)
{
return;
}
coverToken = new CancellationTokenSource();
Sprite sprite = null;
try
{
// Debug.Log($"LevelCard {GetHashCode()}: Loading " + level.Id);
// DebugGUI.Log($"LevelCard {GetHashCode()}: Loading " + level.Id);
var width = 576;
var height = 360;
if (Context.Player.Settings.GraphicsQuality <= GraphicsQuality.Medium)
{
if (Context.Player.Settings.GraphicsQuality <= GraphicsQuality.Low)
{
width = 288;
height = 180;
}
else
{
width = 432;
height = 270;
}
}
// It's possible that this level now has a local version
if (!Level.IsLocal && Level.OnlineLevel.HasLocal(LevelType.User))
{
Level = Level.OnlineLevel.ToLevel(LevelType.User);
}
if (Level.IsLocal)
{
var path = "file://" + Level.Path + LevelManager.CoverThumbnailFilename;
try
{
sprite = await Context.replacedetMemory.Loadreplacedet<Sprite>(path, replacedetTag.LocalLevelCoverThumbnail,
coverToken.Token, options: new SpritereplacedetOptions(new[] {width, height}));
}
catch
{
return;
}
}
else
{
try
{
var path = Level.OnlineLevel.Cover.ThumbnailUrl;
sprite = await Context.replacedetMemory.Loadreplacedet<Sprite>(path, replacedetTag.RemoteLevelCoverThumbnail,
coverToken.Token,
new SpritereplacedetOptions(new[] {width, height}));
}
catch
{
return;
}
}
}
catch (Exception e)
{
Debug.LogWarning(e);
if (sprite != null)
{
// Should be impossible
Destroy(sprite.texture);
Destroy(sprite);
}
return;
}
if (this == null || transform == null) return;
if (sprite != null)
{
lock (sprite)
{
if (sprite != null)
{
if (cover == null) return;
cover.sprite = sprite;
cover.DOFade(0.7f, 0.2f);
cover.FitSpriteAspectRatio();
loadedCover = true;
}
}
}
coverToken = null;
}
19
View Source File : RecordCard.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public async void LoadCover()
{
loadedCover = false;
cover.DOKill();
cover.SetAlpha(0);
if (coverToken != null)
{
if (!coverToken.IsCancellationRequested) coverToken.Cancel();
coverToken = null;
}
if (DoNotLoadCover)
{
coverToken = new CancellationTokenSource();
try
{
await UniTask.WaitUntil(() => !DoNotLoadCover, cancellationToken: coverToken.Token);
}
catch
{
return;
}
}
if (!((RectTransform) transform).IsVisible())
{
coverToken = new CancellationTokenSource();
try
{
await UniTask.WaitUntil(() => ((RectTransform) transform).IsVisible(),
cancellationToken: coverToken.Token);
await UniTask.DelayFrame(0);
}
catch
{
return;
}
}
coverToken = new CancellationTokenSource();
Sprite sprite = null;
try
{
try
{
const int width = 576;
const int height = 216;
var path = record.chart.level.Cover.ThumbnailUrl;
sprite = await Context.replacedetMemory.Loadreplacedet<Sprite>(path, replacedetTag.RecordCoverThumbnail,
coverToken.Token,
new SpritereplacedetOptions(new[] {width, height}));
}
catch
{
return;
}
}
catch (Exception e)
{
Debug.LogWarning(e);
if (sprite != null)
{
// Should be impossible
Destroy(sprite.texture);
Destroy(sprite);
}
return;
}
if (sprite != null)
{
lock (sprite)
{
if (sprite != null)
{
if (cover == null) return;
cover.sprite = sprite;
cover.DOFade(0.15f, 0.2f);
cover.FitSpriteAspectRatio();
loadedCover = true;
}
}
}
coverToken = null;
}
19
View Source File : TransitionElement.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public async void StartTransition(
bool toShow,
Transition transition,
float multiplier,
float duration,
float delay,
Ease ease,
bool waitForTransition,
bool immediate,
Action onComplete = null
)
{
if (!specifiedDefault)
{
Debug.LogWarning(gameObject.name + ": Not specified default for TransitionElement!");
}
if (printDebugInfo)
{
print(gameObject.name + $" StartTransition(toShow: {toShow}, transition: {transition}, multiplier: {multiplier}, duration: {duration}, delay: {delay}, ease: {ease}," +
$"waitForTransition: {waitForTransition}, immediate: {immediate})");
print(StackTraceUtility.ExtractStackTrace());
}
if (toShow == IsShown)
{
onComplete?.Invoke();
return;
}
IsShown = toShow;
if (immediate)
{
waitForTransition = false;
duration = 0;
delay = 0;
}
waitingForTransition?.Cancel();
waitingForTransition = new CancellationTokenSource();
if (IsInTransition)
{
if (toShow == IsEntering) return; // Cancel same operation
if (waitForTransition)
{
try
{
await UniTask.WaitUntil(() => !IsInTransition, cancellationToken: waitingForTransition.Token);
}
catch
{
return;
}
}
else
{
transitioning.ForEach(it => it.Cancel());
transitioning.Clear();
canvasGroup.DOKill();
}
}
var cancellationTokenSource = new CancellationTokenSource();
transitioning.Add(cancellationTokenSource);
IsInTransition = true;
IsEntering = toShow;
if (delay > 0)
{
try
{
await UniTask.Delay(TimeSpan.FromSeconds(delay), cancellationToken: cancellationTokenSource.Token);
}
catch
{
// Cancelled
IsInTransition = false;
return;
}
}
if (this == null) return;
RevertToDefault();
canvasGroup.alpha = toShow ? 0 : 1;
canvasGroup.blocksRaycasts = toShow && !disableRaycasts;
if (duration > 0)
{
canvasGroup.DOFade(toShow ? 1 : 0, duration);
}
else
{
canvasGroup.alpha = toShow ? 1 : 0;
}
if (toShow)
{
onEnterStarted.Invoke();
switch (transition)
{
case Transition.Top:
rectTransform.ShiftPivot(new Vector2(0.5f, 0.5f));
rectTransform.localScale = defaultScale * (2f * multiplier);
rectTransform.DOScale(defaultScale, duration).SetEase(ease);
break;
case Transition.Bottom:
rectTransform.ShiftPivot(new Vector2(0.5f, 0.5f));
rectTransform.localScale = defaultScale * (0.5f / multiplier);
rectTransform.DOScale(defaultScale, duration).SetEase(ease);
break;
case Transition.Left:
rectTransform.ancreplaceddPosition =
defaultAncreplaceddPosition.DeltaX(-rectTransform.rect.width * (0.5 * multiplier));
rectTransform.DOAnchorPos(defaultAncreplaceddPosition, duration).SetEase(ease);
break;
case Transition.Right:
rectTransform.ancreplaceddPosition =
defaultAncreplaceddPosition.DeltaX(rectTransform.rect.width * (0.5 * multiplier));
rectTransform.DOAnchorPos(defaultAncreplaceddPosition, duration).SetEase(ease);
break;
case Transition.Up:
rectTransform.ancreplaceddPosition =
defaultAncreplaceddPosition.DeltaY(rectTransform.rect.height * (0.5 * multiplier));
rectTransform.DOAnchorPos(defaultAncreplaceddPosition, duration).SetEase(ease);
break;
case Transition.Down:
rectTransform.ancreplaceddPosition =
defaultAncreplaceddPosition.DeltaY(-rectTransform.rect.height * (0.5 * multiplier));
rectTransform.DOAnchorPos(defaultAncreplaceddPosition, duration).SetEase(ease);
break;
}
}
else
{
onLeaveStarted.Invoke();
switch (transition)
{
case Transition.Top:
rectTransform.ShiftPivot(new Vector2(0.5f, 0.5f));
rectTransform.DOScale(defaultScale * (2f * multiplier), duration).SetEase(ease);
break;
case Transition.Bottom:
rectTransform.ShiftPivot(new Vector2(0.5f, 0.5f));
rectTransform.DOScale(defaultScale * (0.5f / multiplier), duration).SetEase(ease);
break;
case Transition.Left:
rectTransform
.DOAnchorPos(defaultAncreplaceddPosition.DeltaX(-rectTransform.rect.width * (0.5 * multiplier)),
duration).SetEase(ease);
break;
case Transition.Right:
rectTransform
.DOAnchorPos(defaultAncreplaceddPosition.DeltaX(rectTransform.rect.width * (0.5 * multiplier)),
duration).SetEase(ease);
break;
case Transition.Up:
rectTransform
.DOAnchorPos(defaultAncreplaceddPosition.DeltaY(rectTransform.rect.height * (0.5 * multiplier)),
duration).SetEase(ease);
break;
case Transition.Down:
rectTransform
.DOAnchorPos(defaultAncreplaceddPosition.DeltaY(-rectTransform.rect.height * (0.5 * multiplier)),
duration).SetEase(ease);
break;
}
}
if (duration > 0)
{
try
{
await UniTask.Delay(TimeSpan.FromSeconds(duration), cancellationToken: cancellationTokenSource.Token);
}
catch
{
// Cancelled
IsInTransition = false;
}
}
IsInTransition = false;
onComplete?.Invoke();
if (toShow) onEnterCompleted.Invoke();
else onLeaveCompleted.Invoke();
}
19
View Source File : GamePreparationScreen.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public override void OnScreenBecameActive()
{
base.OnScreenBecameActive();
if (Context.SelectedLevel == null)
{
Debug.LogWarning("Context.SelectedLevel is null");
return;
}
ProfileWidget.Instance.Enter();
Context.LevelManager.OnLevelMetaUpdated.AddListener(OnLevelMetaUpdated);
Context.OnlinePlayer.OnLevelBestPerformanceUpdated.AddListener(OnLevelBestPerformanceUpdated);
Context.OnSelectedLevelChanged.AddListener(OnSelectedLevelChanged);
}
19
View Source File : TierSelectionScreen.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
private IEnumerator SnapCoroutine(string tierId = null)
{
while (Math.Abs(scrollRect.velocity.y) > 1024)
{
yield return null;
}
yield return null;
var tierCards = scrollRect.GetComponentsInChildren<TierCard>().ToList();
if (tierCards.Count <= 1)
{
snapCoroutine = null;
yield break;
}
try
{
TierCard toTierCard;
if (tierId == null)
{
toTierCard = tierCards
.FindAll(it => !it.Tier.isScrollRectFix)
.MinBy(it => Math.Abs(it.rectTransform.GetScreenSpaceCenter(it.canvas).y - ScreenCenter.y));
scrollRect.SrollToCell(toTierCard.Index, 1024);
}
else
{
toTierCard = tierCards.FirstOrDefault(it => it.Tier.Id == tierId);
if (toTierCard == null) toTierCard = tierCards[0];
scrollRect.SrollToCell(toTierCard.Index, 1024);
}
selectedTierCard = toTierCard;
OnTierSelected(toTierCard.Tier);
}
catch (Exception e)
{
Debug.LogWarning(e);
tierCards.FindAll(it => !it.Tier.isScrollRectFix).ForEach(it => print(Math.Abs(it.rectTransform.GetScreenSpaceCenter(it.canvas).y - ScreenCenter.y)));
}
snapCoroutine = null;
}
19
View Source File : Player.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public void LoadSettings()
{
Context.Database.Let(it =>
{
if (!it.CollectionExists("settings"))
{
Debug.LogWarning("Cannot find 'settings' collections");
}
var col = it.GetCollection<LocalPlayerSettings>("settings");
var result = col.FindOne(x => true);
if (result == null)
{
Debug.LogWarning("First time startup. Initializing settings...");
// TODO: Remove migration... one day
ShouldMigrate = true;
result = InitializeSettings();
col.Insert(result);
}
Settings = result;
FillDefault();
Settings.TotalLaunches++;
SaveSettings();
});
}
19
View Source File : BundleManager.cs
License : GNU General Public License v3.0
Project Creator : Cytoid
License : GNU General Public License v3.0
Project Creator : Cytoid
public async UniTask Initialize()
{
// Get built-in catalog first
BundleCatalog builtInCatalog;
using (var request = UnityWebRequest.Get(BuiltInCatalogPath))
{
await request.SendWebRequest();
var text = Encoding.UTF8.GetString(request.downloadHandler.data);
builtInCatalog = new BundleCatalog(JObject.Parse(text));
}
// Then the cached catalog
if (File.Exists(CachedCatalogPath))
{
Debug.Log($"[BundleManager] Reading cached catalog from {CachedCatalogPath}");
using (var request = UnityWebRequest.Get("file://" + CachedCatalogPath))
{
var valid = true;
try
{
await request.SendWebRequest();
if (request.isHttpError || request.isNetworkError)
{
throw new Exception(request.error);
}
var text = Encoding.UTF8.GetString(request.downloadHandler.data);
Catalog = new BundleCatalog(JObject.Parse(text));
foreach (var bundleName in builtInCatalog.GetEntryNames())
{
if (!Catalog.ContainsEntry(bundleName))
{
valid = false;
break;
}
var cachedVersion = Catalog.GetEntry(bundleName).version;
var builtInVersion = builtInCatalog.GetEntry(bundleName).version;
if (builtInVersion > cachedVersion)
{
Debug.Log($"[BundleManager] Bumping {bundleName} from {cachedVersion} to {builtInVersion}");
Catalog.SetEntry(bundleName, Catalog.GetEntry(bundleName).JsonDeepCopy().Also(it => it.version = builtInVersion));
}
}
}
catch (Exception e)
{
Debug.LogWarning(e);
valid = false;
}
if (!valid)
{
Debug.Log($"[BundleManager] Invalid cached catalog! Using built-in catalog");
Catalog = builtInCatalog;
}
}
}
else
{
Catalog = builtInCatalog;
}
var cachePaths = new List<string>();
Caching.GetAllCachePaths(cachePaths);
cachePaths.ForEach(it => Debug.Log($"[BundleManager] Cache path: {it}"));
// Always cache built in bundles
foreach (var bundle in builtInCatalog.GetEntryNames())
{
if (IsCached(bundle) && IsUpToDate(bundle))
{
Debug.Log($"[BundleManager] Built-in bundle {bundle} is cached and up-to-date (version {Catalog.GetEntry(bundle).version})");
continue;
}
await LoadBundle(bundle, true, false);
Release(bundle);
}
}
See More Examples