Skip to content

Instantly share code, notes, and snippets.

View junaid109's full-sized avatar
🏠
Working from home

Junaid Malik junaid109

🏠
Working from home
View GitHub Profile
@junaid109
junaid109 / VideoPlayerController.cs
Created March 28, 2024 11:05
Simple script to play video with avpro
using UnityEngine;
using RenderHeads.Media.AVProVideo;
public class VideoPlayerController : MonoBehaviour
{
public string videoURL = "YOUR_VIDEO_URL_HERE";
public bool playOnStart = true;
private MediaPlayer mediaPlayer;
List<Device> childDevices = new List<Device>
{
new Device { Id = 1 },
};
List<Device> parentDevices = new List<Device>
{
new Device { Id = 1 }, // Parent device with ID 1
new Device { Id = 4 } // Parent device with ID 4
@junaid109
junaid109 / LinkRectTransforms.cs
Created June 7, 2023 14:29
Link React Trans forms
using UnityEngine;
public class LinkRectTransforms : MonoBehaviour
{
public RectTransform rectTransform1;
public RectTransform rectTransform2;
private void Update()
{
// Get the current position of the right edge of RectTransform1
@junaid109
junaid109 / GLTFImportMenu.cs
Created May 25, 2023 09:40
GLTFImportMenu
using UnityEditor;
using UnityEngine;
public class GLTFImportMenu : EditorWindow
{
[MenuItem("Custom/GLTF Import")]
static void Init()
{
GLTFImportMenu window = (GLTFImportMenu)EditorWindow.GetWindow(typeof(GLTFImportMenu));
window.Show();
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CanvasItemScale : MonoBehaviour
{
public CanvasScaler target;
public RectTransform targetTransform;
@junaid109
junaid109 / Program.cs
Created May 16, 2023 09:21
demonstrates a static string being accessed and updated by multiple threads using a lock for synchronization:
//demonstrates a static string being accessed and updated by multiple threads using a lock for synchronization:
using System;
using System.Threading;
public class Program
{
// Static string variable
private static string sharedString = "Initial Value";
using System;
using System.Management;
namespace DeviceStatsLogger
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Retrieving device stats...");
@junaid109
junaid109 / Joystick.cs
Created February 23, 2023 10:59
Simple Joystick Script Unity
using UnityEngine;
public class JoystickCameraController : MonoBehaviour
{
public float joystickSensitivity = 0.1f;
public float rotationSpeed = 5f;
public float zoomSpeed = 2f;
private Vector2 joystickInput;
private Transform cameraTransform;
@junaid109
junaid109 / PostUnity.cs
Created October 3, 2022 10:41
Post method in unity
private IEnumerator PostRegistrationDetails(string jsonData)
{
var raw = Encoding.UTF8.GetBytes(jsonData);
using UnityWebRequest webRequest = UnityWebRequest.Post(uriPostResults, "POST");
webRequest.SetRequestHeader("Content-Type", "application/json");
webRequest.uploadHandler = new UploadHandlerRaw(raw);
webRequest.uploadHandler.contentType = "application/json";
webRequest.downloadHandler = new DownloadHandlerBuffer();
webRequest.SendWebRequest();
if (webRequest.isNetworkError || webRequest.isHttpError)
@junaid109
junaid109 / .deps...npm...@openzeppelin...contracts...token...ERC20...ERC20.sol
Created August 13, 2022 17:36
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.2+commit.661d1103.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**