Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

xavierarpa/XavHelpTo

Repository files navigation

XavHelpTo

Helper to handle Unity code scenarios

~ XavHelpTo it's a DLL where you'll find methods to handle a variety of situations based of what you expect to when we are making games on Unity

How to Install

  • You must have a Unity Project
  • You must have to install Git (https://git-scm.com/downloads) (Maybe you'll have to reboot after install)
  • Go to the Package Manager Window
  • Click in the '+' icon
  • Click on the option Add package from git URL...
  • Paste the git link: https://github.com/kingdox/XavHelpTo.git on it
  • Wait some seconds...
  • Installed 😎 👍

Helper Classes

  • Supply

    General class, this includes the most common methods. Frequently used methods:
    • T Component<C, T>: Get the Component and set on a ref variable, also allows you can chain methods, if it can't find it, you can add it too. Instead of: Button btn_back = gameObject.GetComponent<Button>(); btn_back.interactable = true; btn_back.onClick.AddListener(Back); Why not:
          // Look you're not typing any type, because is implicit on the variable 'btn_back'
          this.Component(out btn_back).interactable = true; 
          btn_back.onClick.AddListener(Back);
    • T[] Components: Get the same Component of every child of a Transform (Excluding itself) example:
          //Where 'btn_buyItems' represent a Button[]
          this.Components(out btn_buyItems);
    • void ClearChilds: Destroy every GameObject child of a Transform parent example:
          transform_parentItems.ClearChilds();
    • void Singleton: Apply the Singleton Pattern, also can include a Object.DontDestroyOnLoad example:
          //'this' means the class to be unique and instance means the static variable of the Type
          this.Singleton(ref instance);
    • Lenght(): Returns the Qty of key elements on a Enum
      enum WordType{
          A = -1,
          B = 2,
          C = 0
      }
      //returns 3
      Supply.Lenght<WordType>(); 
    • T Print(): One of the most useful Methods, Used to debug whenever you want, adding a Color if you want (or a random)
      int a = 1;
      int b = 2;
      int c = 3;
      //Look that you can add it in each part of your code, this is useful when you whant to debug each piece of code on a specified moment without any alteration of the formula
      int result = ((2*b).Print("red") / (a-c).Print("blue"));
      string displayedResult = $"on a:{a},b:{b} and c:{c}, \n the result is {result}".Print("magenta");
      return displayedResult;
  • Get.Get

    Class based on obtention of data Frequently used methods:
    • T Any(): Returns any item of an Array
     Transform tr_target = tr_targets.Any();
    • int ZeroMax(): Returns a random value betweeen 0 and the specified int
    100.ZeroMax();
    100f.ZeroMax();
    array.ZeroMax();
    • float Max(): returns a value clamped on the Max value
    int percent = value.Max(100);
    • float Min(): returns a value clamped on the Min value
    int life = (life - damage).Min(0);

these are other clases

Know.Know (Allows you to know things like index, timing or iterators) Set.Set Change.Change EditWindow.EditWindow Look.Look

About

Tool to manage code scenarios

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published