Skip to content

Instantly share code, notes, and snippets.

View Cdddo's full-sized avatar

Carlos Diosdado Cdddo

  • Hypertectonics
  • Mexico
View GitHub Profile
@Cdddo
Cdddo / InternetCheck.cs
Last active June 17, 2023 00:17
Internet Check
using System.Net.NetworkInformation;
public static bool CheckForInternetConnection()
{
try
{
using (var ping = new Ping())
{
var result = ping.Send("8.8.8.8", 2000);
return result.Status == IPStatus.Success;
@Cdddo
Cdddo / ExampleInput.cs
Last active September 8, 2022 12:33
Input Example
using UnityEngine;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
/// <summary>
/// A standard wrapper for receiving input from the
/// <see href="https://docs.unity3d.com/Packages/com.unity.inputsystem@latest">Input System</see> package or the
/// <see href="https://docs.unity3d.com/Manual/class-InputManager.html">Legacy Input Manager</see>.
@Cdddo
Cdddo / UnityToGoogleForms.cs
Last active September 7, 2022 22:12
Unity to Google Forms
// https://github.com/luzan/Unity-Google-Spreadsheet
// Save data from Unity to Google Spreadsheet
// No Authentication, plugins, SDK required
///<summary>
/// Here we’ll be creating a Google Form that will save the responses to the Google Spreadsheet an using few tricks we will replicate that form into our Unity App, so that the data to the Google Form will now be feed from Unity App.
/// So, our first step is to create a Google Form. Login to Google Forms with Google Account and create a Google form. New /// Google Form will have fields and entries that are similar to what you are trying to keep on unity app.
/// After creation of Form, start a Unity Project and create similar form on the 2D Canvas by adding Input Fields.
/// A few things on the scripts are achieved from Source Code of the Google Forms, to get that follow these steps:
@Cdddo
Cdddo / savetojson.cs
Created September 6, 2022 20:33
yanr save to json
private string SerializeAllVariablesToJSON()
{
(var floats, var strings, var bools) = _variableStorage.GetAllVariables();
SaveData data = new SaveData();
data.floatKeys = floats.Keys.ToArray();
data.floatValues = floats.Values.ToArray();
data.stringKeys = strings.Keys.ToArray();
data.stringValues = strings.Values.ToArray();
data.boolKeys = bools.Keys.ToArray();
@Cdddo
Cdddo / selectonenable
Last active September 6, 2022 18:37
Auto Select On Enable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class SelectOnEnable : MonoBehaviour
{
void OnEnable()
{
// clear any selected objects
@Cdddo
Cdddo / YarnSpinnerNotes.md
Last active September 6, 2022 22:24
Yarn Spinner Notes

Trying to call Stop() alone just makes the current line replay, which is very much not what I want What I want is just to be able to dismiss the current line and prevent any new ones from being delivered, same as if I had put <> in the yarn script

https://discord.com/channels/754171172693868585/754171643990900776/983937895528267827 I think I know what’s happening, we stop the dialogue but we don’t tell the views that this has happened. So when the view finishes up it tells the runner to continue which then starts it all up again

Q: Dialogue Runner still runs after calling DialogueRunner.Stop(). Dialogue line view doesn't close either. Am I missing something here?

A: If you call Stop() on a dialogue runner while a line is running, and then your line view reports that the line is complete, the dialogue runner will call its Continue() method, which resumes running. If you call Stop(), don’t call the onDialogueLineFinished callback from your dialogue view (or any other callback)

@Cdddo
Cdddo / lambda_function.py
Last active May 5, 2021 18:59
AWS Lambda function to fix metadata for Unity WebGL build files
# This function should be invoked from event triggers from objects being created, filtered by the .br or .gz suffix
# Note that for system-defined values like Content-Encoding and Content-Type, we have to assign them directly
# Reference https://stackoverflow.com/a/66009750
import boto3
s3 = boto3.client('s3')
def lambda_handler(event, context):
@Cdddo
Cdddo / repo-reset.md
Last active May 28, 2022 18:23 — forked from heiswayi/repo-reset.md
GitHub - Delete commits history with git commands

Repo Reset

If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP

# Commit the files:
git commit -m "Initial commit"