Uploaded by Leon Chan

Unity Notes - Copy

advertisement
Unity Notes
1) Dropdown font size
To do this, i changed
- Dropdown > Template > Viewport > Content : Height 50
- Dropdown > Template > Viewport > Content > Item : Height 50,f
- Dropdown > Template > Viewport > Content > Item > Item Label : Font size 24, bold, italic, Vertical
Overflow
2) scroll view
- vertical layout group(layout) + content size fitter(parent)
- OR vertical layout group(parent) + layout element (child)
- vertical layout group setting (check control child size + child force expand) (uncheck use child scale)
3) Set input field text  GetComponent<InputField>.text() = “XXX”
4) Access Dropdown value : Debug.Log(Dropdown.options[Dropdown.value].text);
3) scroll bar
-
-
SQL hash value :
INSERT INTO User
VALUES(000001,"TestUser", UNHEX(SHA2('abc123',256)), "test@gmail.com", "Player",
"Active", 0)
SQL Left Join Multiple Table
e.g. SELECT Student.Name, School.Name, PersonalInformation.DateOfBirth,
PersonalInformation.Gender
FROM Student
LEFT JOIN PersonalInformation
ON Student.UserID = PersonalInformation.UserID
LEFT JOIN School
ON Student.School = School.ShortForm
6) Scroll Bar fix handle size:
In Scroll Rect (Script) Component
Set Movement Type = Clamped
On Value Changed (Single) add new, Drag Scrollbar (Script), Set Scrollbar\float
size, set value = 0 (0.4/0.3 works for me)
Then set scroll bar and sliding area ge top and bottom to 0. After that, turn the
position
And use Update() to set scrollbar.size = 0
And add a function to disable this script once on valuechange is called to avoid
wasting cpu on updating the scrollbar.size
I do this because setting the size in awake do not work.
7) Insert Date
INSERT INTO PersonalInformation
VALUES(3, "F", STR_TO_DATE('2020-10-31', '%Y-%m-%d'), "Test Primary School", "Hong Kong", "zhyue")
8) PHP get the last insert id (from auto increment)
$con = mysqli_connect("localhost", "leonctl", "leonCTL21@!", "DLTD");
$createLoginSessionQuery = mysqli_query ($con,
"INSERT INTO LoginSession
VALUES(NULL, '$UserID', NULL, '$loginTime', NULL);"
);
$outputArray["LoginSessionID"] =$con->insert_id;
9) Get which button is calling the function
EventSystem.current.currentSelectedGameObject.name
10) Texture2D to sprite remember to [Texture2D].Apply(); Before Sprite.Create(…);
11) php don’t add string, use . operation (concat) e.g. “0x”.$password
12) php convert string to Binary type: concat “0x” in the front
13) delegate = container for function , like variables for values
Sample Code 1 (call multiple function with single call):
Sample Code 2:
14) Event: broadcast system, when it will trigger the different functions of all the subscribers
When you want to call multiple func in one class use delegate; When you want to call funct from
different classes, user event
Sample Code:
Set up Event
Subscriber 1:
Subscriber 2:
15. Coroutine: yield return null = the code in the coroutine will resume after the next update
16) add option by script:
schoolDropdown.options.Add(new Dropdown.OptionData { text = schoolName});
17) set parent for gameObject
myNewSmoke.transform.parent = gameObject.transform;
17) SQL Timestamp add
TIMESTAMPADD(MONTH,2,'2009-05-18')
18) php sql compare string with UNHEXed binary 32:
$password = “6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b”
User.Password = UNHEX('$password')
19) Pass Array in PUN RPC need to cast object
(e.g.) photonView.RPC("EventSkillExecution", RpcTarget.All, (object)targetIDsArray);
20) Iterate and Remove from list
safePendingList.RemoveAll(item => item.Value == someValue);
21) scroll view/rect bound back  content too short, add a content size fitter
22) 2D Particle System using sprite
Step 1) Render Material: sprite default
Step 2) Texture Sheet Animation  Mode: Sprite
Download