Skip to content

Instantly share code, notes, and snippets.

View MuhammadFaizanKhan's full-sized avatar

Muhammad Faizan Khan MuhammadFaizanKhan

View GitHub Profile
@MuhammadFaizanKhan
MuhammadFaizanKhan / MaterialPickOnClick.cs
Created May 2, 2024 06:02
If you have a single mesh renderer component containing a list of materials and you need to detect the correct material (or sub-mesh) at runtime upon a mouse click, then this script is exactly what you need. Simply attach this script to any game object. Ensure that the object requiring material selection has a collider component attached
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MaterialPickOnClick : MonoBehaviour
{
void Update()
{
if (Input.GetMouseButtonDown(0))
@MuhammadFaizanKhan
MuhammadFaizanKhan / TogglePlayAnimation
Created May 9, 2020 07:06
Play Unity legacy animation on click, click again to play animation in reverse. click and toggle animation
using UnityEngine;
public class AnimationController : MonoBehaviour
{
[SerializeField]
Animation anim;
[SerializeField]
string clipName;
@MuhammadFaizanKhan
MuhammadFaizanKhan / SerilogDemoInUnity3d
Created April 21, 2020 14:35
How to use Serilog in Unity3d C#
using UnityEngine;
using Serilog;//Need dll files
public class SerilogDemoInUnity3d : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
var log = new LoggerConfiguration().WriteTo.File(Application.dataPath + "/AppLog.txt").CreateLogger();
@MuhammadFaizanKhan
MuhammadFaizanKhan / NavMeshAgentWalkOnClickPosition
Created April 19, 2020 08:50
Nav Mesh agent will walk on mouse click position.
using UnityEngine;
using UnityEngine.AI;
public class NavController : MonoBehaviour
{
NavMeshAgent agent;
// Start is called before the first frame update
void Start()
{
agent = GetComponent<NavMeshAgent>();
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using UnityEngine;
public class SendEmail : MonoBehaviour
{
public string fromEmail = "yourGmailAccountFromWhereYouWantToSendEmail";
public string toEmail = "WhomYouWantToSendEmail";
@MuhammadFaizanKhan
MuhammadFaizanKhan / FileExtensionConverter.cs
Created March 30, 2018 12:02
File Extension Converter - Convert selected extension files from a folder to desired extension.
namespace FileExtensionConverter
{
class Program
{
static void Main(string[] args)
{
bool quitApp = false;
do
{
Console.WriteLine("\t\t\t**Files Extension Converter**");
@MuhammadFaizanKhan
MuhammadFaizanKhan / PDOFunctionsDemo.php
Last active April 30, 2023 22:35
Insert, Update, Delete and Select with PHP, PDO and MySQL
<?php
/**
* Created by PhpStorm. * User: Faizan Khan * Date: 1/2/2018 * Time: 10:51 AM
*/
/*Script Motive: The purpose of the file is to present different PDO Functions for DML and DDL operations
Sample Table
Table Name: UserTbl
Columns: Id, UserName, Email, RecordAddDate
*/
@MuhammadFaizanKhan
MuhammadFaizanKhan / ImageToGrayscale.py
Last active March 13, 2024 17:08
Coverting image to grayscale in opencv python
import cv2
import sys
# reading image and saving in a var
image = cv2.imread(sys.argv[1]) # The first argument is the image, getting from command line
print("image shape")
print(image.shape)
# Convert to Grayscale
@MuhammadFaizanKhan
MuhammadFaizanKhan / OpenCVImageLoad.py
Last active January 24, 2018 07:38
How to Load image in OpenCV
import cv2 #Import openCV
import sys #import Sys. Sys will be used for reading from the command line. We give Image name parameter with extension when we will run python script
#Read the image. The first Command line argument is the image
image = cv2.imread(sys.argv[1]) #The function to read from an image into OpenCv is imread()
#imshow() is the function that displays the image on the screen.
#The first value is the title of the window, the second is the image file we have previously read.
cv2.imshow("OpenCV Image Reading", image)
@MuhammadFaizanKhan
MuhammadFaizanKhan / ObjectMovmentOnWayPoints.cs
Created December 14, 2017 07:40
Move object on way points in unity3d
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectMovmentOnWayPoints : MonoBehaviour
{
#region Vars
public List<GameObject> movmentWayPoints;