Categories
Uncategorized

Unity – Get Targets in Range

public float           MaxAimRange = 10f;
public List<Transform> targets;
public Vector2 targetingSensorPosition;


// Start is called before the first frame update
void Start() {
  targetingSensorPosition = GetComponent<Transform>().position;
}


private void GetTargetsInRange() {
  var myContactFilter   = new ContactFilter2D();
  var collidersInCircle = new List<Collider2D>();
  var numFound          = Physics2D.OverlapCircle(
                                   targetingSensorPosition,
                                   MaxAimRange, 
                                   myContactFilter,
                                   collidersInCircle);

  Debug.Log("count of colliders: " + collidersInCircle.Count);
  Debug.Log("numFound: " + numFound);
Categories
Uncategorized

Scriptable Object

Categories
Uncategorized

C# Unity Coroutine

using UnityEngine;
using System.Collections;

// In this example we show how to invoke a coroutine and
// continue executing the function in parallel.

public class ExampleClass : MonoBehaviour
{
    // In this example we show how to invoke a coroutine and
    // continue executing the function in parallel.

    private IEnumerator coroutine;

    void Start()
    {
        // - After 0 seconds, prints "Starting 0.0"
        // - After 0 seconds, prints "Before WaitAndPrint Finishes 0.0"
        // - After 2 seconds, prints "WaitAndPrint 2.0"
        print("Starting " + Time.time);

        // Start function WaitAndPrint as a coroutine.

        coroutine = WaitAndPrint(2.0f);
        StartCoroutine(coroutine);

        print("Before WaitAndPrint Finishes " + Time.time);
    }

    // every 2 seconds perform the print()
    private IEnumerator WaitAndPrint(float waitTime)
    {
        while (true)
        {
            yield return new WaitForSeconds(waitTime);
            print("WaitAndPrint " + Time.time);
        }
    }
}
Categories
Uncategorized

C# in Unity

Categories
Uncategorized

Laravel DB Query Log

DB::enableQueryLog();

$user= DB::table('users')->get();

dd(DB::getQueryLog());