Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////Welcome to my notes where i throw a bunch of information i need to go back and look at but probably wont
- /*
- ////-=-=-=- Things To Learn -=-=-=-////
- Generics
- Lambda
- c# recursive function
- Dependacy
- //For Unity
- c# function design pattern
- //you dont need to use singletons
- 1. singleton = https://youtu.be/mpM0C6quQjs
- 2. Abstract Factory = https://youtu.be/vj_3b9JXaZE
- 3. Factory Method https://youtu.be/xN7EFHU_rXA
- 4. Builder https://youtu.be/R-_Ud2egx7M
- 5. Prototype
- 6. Adapter
- 7. Bridge
- 9. Composite
- 10. Decorator
- 11. Facade
- 12. Flyweight
- 13. Proxy
- 14. hain of Responsibility
- 15. Command
- 16. Interpreter
- 17. Iterator
- 18. Mediator
- 18. Memento
- 20. Observer
- 21. State
- 22. Strategy
- 23. Template Method
- 24. Visitor
- and i cant think of enything elses beacus i dont know what i dont know
- Notes:
- Concatenate = “1”+”2” = “12”
- //Shorter If statement
- variavleA = VariableB?.someField;
- is equivalent to
- if (VariableB== null)
- variavleA = null;
- else
- variavleA = VariableB.someField;
- and
- VariableB?.SomeMethod();
- to
- if (VariableB != null)
- VariableB.SomeMethod();
- //transform.LookAt(2 * transform.position - lookingAt.position);
- */
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Text;
- using UnityEngine.Events;
- using Microsoft;
- using UnityEngine.Lumin;
- using System.IO;
- using UnityEngine.Networking;
- using System;
- using UnityEngine.UI;
- using TMPro;
- //you can add if statements to just about anything for just about any reason
- #if ENABLE_INPUT_SYSTEM
- using UnityEngine.InputSystem;
- #endif
- //make it so your script requires stuff inorder to use to reduce the chance of errors
- [RequireComponent(typeof(GameObject))]
- public class UnityNotes : MonoBehaviour
- {
- //list Class
- public List<myListClass> _myListClass = new List<myListClass>();
- //setup restrictions like you and only send or receve
- public int settersAndGetter { get; set; }
- //test UI Button
- private Button[] teleportButtons = defult;//im not sure what defult is, might need to look into that more
- //mulypurpose function overriding
- public void Example(int myInt) {
- //Do Something
- }
- public void Example(Color myColor)
- {
- //DoSomething
- }
- public void Example(int myInt, Color myColor)
- {
- Example(myInt);
- Example(myColor);
- }
- //==== Variable Function (parameter) ====// "arguments" (or "parameters" interchangeably)
- public bool GreaterThanFive(int value) {
- if (value > 5)
- return true;
- else
- return false;
- }
- //regions are a good way to organise and make code less overwelming
- #region Basics
- //overloading (the different versions of a method with a same name are "overloads")
- public void Example(int myInt) {
- //Do Something
- }
- public void Example(Color myColor)
- {
- //DO Something
- }
- public void Example(int myInt, Color myColor)
- {
- Example(myInt);
- Example(myColor);
- }
- private int sgExample_1;
- public int settersAndGetter_2
- {
- get
- {
- return sgExample_1;
- }
- set
- {
- value = sgExample_1;
- }
- }
- //==== START ====//
- // Start is called before the first frame update
- void Start()
- {
- StartCoroutine(CoroutineExample());
- SetupTeleportButtons();
- }
- //==== End START ====//
- // Update is called once per frame
- void Update()
- {
- }
- #endregion
- IEnumerator CoroutineExample()
- {
- while (true) {
- MyShortFunction();
- yield return new WaitForSeconds(1);
- }
- }
- //This is a neet thing you can do to buttons, you can asighn functions to them withought using the on click event
- public void SetupTeleportButtons() {
- testbutton.onClick.AddListener(() =>
- {
- if(true)
- TestButton("Button Pushed");
- });
- }
- public void TestButton(string testtext)
- {
- Debug.Log(testtext);
- }
- //Short function
- private void MyShortFunction() => Debug.Log("This is a Short Function");
- //==== ExampleFunction ====//
- [ContextMenu("hat")]// this alows you to call it from the editer
- public void ExampleFunction(int index)
- {
- if (index == 0)
- return;
- List<int> values = new List<int>();
- values.Add(1);
- //for loop alows you to loop through lists arrays and dictionaries
- for (int i = 0; i < values.Count; i++)
- {
- if(youWantToSkipForLoop == true)
- {
- //This will stop runing thought the for loop
- continue;
- }
- Debug.Log(values[i]);
- }
- //foreach loop alows you to loop through lists arrays and dictionaries
- foreach (var item in values)
- {
- if(youWantToSkipforeachLoop == true)
- {
- //This will stop runing thought the foreach loop
- continue;
- }
- Debug.Log(item);
- }
- //case switch
- switch (index)
- {
- case 1:
- Debug.Log("index: 5");
- break;
- case 2:
- Debug.Log("index: 4");
- break;
- case 3:
- Debug.Log("index: 3");
- break;
- default:
- Debug.Log("index: 0");
- break;
- }
- Debug.Log($"Test Index Value: {index}");
- }
- }
- [Serializable]//Serializable makes it visable in the editer
- public class myListClass{
- public string name;
- //you can put another listClass in a List class have have list class layers
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement