Skip to content

Latest commit

 

History

History
195 lines (146 loc) · 7.17 KB

File metadata and controls

195 lines (146 loc) · 7.17 KB
Drag me

Enjoy your time here~ ☕

Table of contents

<script> // Make the DIV element draggable: dragElement(document.getElementById("dragged")); function dragElement(elmnt) { var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; if (document.getElementById("draggable")) { // if present, the header is where you move the DIV from: document.getElementById("draggable").onmousedown = dragMouseDown; } else { // otherwise, move the DIV from anywhere inside the DIV: elmnt.onmousedown = dragMouseDown; } function dragMouseDown(e) { e = e || window.event; e.preventDefault(); // get the mouse cursor position at startup: pos3 = e.clientX; pos4 = e.clientY; document.onmouseup = closeDragElement; // call a function whenever the cursor moves: document.onmousemove = elementDrag; } function elementDrag(e) { e = e || window.event; e.preventDefault(); // calculate the new cursor position: pos1 = pos3 - e.clientX; pos2 = pos4 - e.clientY; pos3 = e.clientX; pos4 = e.clientY; // set the element's new position: elmnt.style.top = (elmnt.offsetTop - pos2) + "px"; elmnt.style.left = (elmnt.offsetLeft - pos1) + "px"; } function closeDragElement() { // stop moving when mouse button is released: document.onmouseup = null; document.onmousemove = null; } } </script>

Welcome, to the Unorganised Devlogs

Here, I shall spill my knowledge on what I have learnt in development.

This is what i want to write about so far:

  • String formatting for txts

Btw I was thinking about it and it might be good to sanitize the localization text's in general by doing something like: s = s.TrimEnd('\r', '\n'); //or if using an array, use new[] {"/r/n", "/n/r", "/n", "/r"} or something.
We can't do .Replace because it means we would lose formatting in the already processed localization strings if they have any e.g. a two line string would become a one line

  • Float precision issues

Avoid using comparisons, instead use approximations (refer to epsilon on google), especially applies to the audio player implementation below. You could also use decimal data type, but decimals take up more space.

  • Audio player implementation

I'll just copy pasta, but basically a coroutine to check if the video is ended, and change the logo back

and also this logic: REFER TO THAT ROGUE IMAGE FILE IN THIS DIRECTORY

  • Vertical lines on fonts too thin looking, usually I/lowercase Ls

Adjust the dilate on the font if using TMP, this increases the thickness somewhat, which should solve this issue without making it too bold like if using the bold option

  • Sprite scaling

Use sprite editor to edit borders for 9-slice scaling, so that corners stay consistent while the shape can stretch

  • Array class to List<Foo> casting

So for example

Enum.GetValues(typeof(EnumFoo)).Cast<EnumFoo>().ToList();

Enum.GetValues return a Array class type, which you need to cast to type before ToList();

Otherwise, if Array holds a reference type, then you can just use the shortcut ToList<Obj>() instead.

  • nameof()

nameof is very blunt, too blunt, it returns the immediate variable name fed into it, it doesnt care about the value at all. pls.

  • Android low fps?

Try application.targetframerate or smtg, it should help. On PCs, this can be set either this way, or through vsync, read more in unitydocs for deets

  • Multi-Object editing on editor scripts

Use targets with an 's', instead of target. Because target refers to the current most selected singular object. Then perform your operations there

  • Override sprite?

Just a sprite option that when set to null, defaults to the .sprite instead

  • Child constructors

class Bar   
Bar (var varName)

class Foo : Bar   
Foo (var x, var y) : base(x)
#if !(PLATFORM_ANDROID || UNITY_ANDROID) && !UNITY_EDITOR

    _content.SetActive(false);
#endif

NOTE TO SELF, UPLOAD GABEEXTENSIONS.cs eventually

Hi

Yea? no.