Skip to content

Commit

Permalink
feat: Add UI Layout rebuild extension method
Browse files Browse the repository at this point in the history
Remove WebsocketSharp extensions
Move project to Assets/
  • Loading branch information
Vatsal Ambastha committed Apr 7, 2020
1 parent 04a5075 commit 963451d
Show file tree
Hide file tree
Showing 78 changed files with 52 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
fi
git push -f -u origin upm
env:
PKG_ROOT: "Packages/Adrenak.Unex"
PKG_ROOT: "Assets/Adrenak.Unex"


- name: Create upm git tag
Expand Down
6 changes: 3 additions & 3 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"@semantic-release/release-notes-generator",
["@semantic-release/changelog", {
"preset": "angular",
"changelogFile":"Packages/Adrenak.Unex/CHANGELOG.md"
"changelogFile":"Assets/Adrenak.Unex/CHANGELOG.md"
}],
["@semantic-release/npm", {
"npmPublish": false,
"pkgRoot":"Packages/Adrenak.Unex/"
"pkgRoot":"Assets/Adrenak.Unex/"
}],
["@semantic-release/git", {
"assets": ["Packages/Adrenak.Unex/package.json", "Packages/Adrenak.Unex/CHANGELOG.md"],
"assets": ["Assets/Adrenak.Unex/package.json", "Assets/Adrenak.Unex/CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}],
"@semantic-release/github"
Expand Down
8 changes: 8 additions & 0 deletions Assets/Adrenak.Unex.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using UnityEngine;

namespace Adrenak.Unex {
public static class LanguageExtensions {
public static class CSharpExtensions {
// ENUM
public static bool Has<T>(this Enum type, T value) {
try {
Expand Down Expand Up @@ -56,15 +56,17 @@ public static bool Approximately(this float a, float b) {
return Mathf.Approximately(a, b);
}

// BYTE[]
public static string ToUTF8String(this byte[] bytes) {
return Encoding.UTF8.GetString(bytes);
}


// STRINGS
public static bool IsNullOrEmpty(this string _string) {
return string.IsNullOrEmpty(_string);
}

public static string ToUTF8String(this byte[] bytes) {
return Encoding.UTF8.GetString(bytes);
}

public static byte[] ToUTF8Bytes(this string str) {
return Encoding.UTF8.GetBytes(str);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using UnityEngine;
using UnityEngine.UI;

using System.Collections.Generic;
using System.Threading.Tasks;

using System.Reflection;
using System;
using Object = UnityEngine.Object;
Expand All @@ -13,8 +17,15 @@ public static bool Approximately(this Vector2 a, Vector2 b) {
Mathf.Approximately(a.y, b.y);
}

// GAME OBJECTS
public static void Destroy(this GameObject gameObject) {
public static bool Approximately(this Vector3 a, Vector3 b) {
return
Mathf.Approximately(a.x, b.x) &&
Mathf.Approximately(a.y, b.y) &&
Mathf.Approximately(a.z, b.z);
}

// GAME OBJECTS
public static void Destroy(this GameObject gameObject) {
MonoBehaviour.Destroy(gameObject);
}

Expand Down Expand Up @@ -220,5 +231,17 @@ public static Sprite ToSprite(this Texture2D tex) {
if (tex == null) return null;
return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(.5F, .5F));
}
}

public static Task MarkForUIRebuild<T>(this T t) where T : Component {
return t.gameObject.MarkForUIRebuild();
}

async public static Task MarkForUIRebuild(this GameObject go) {
if (go.GetComponent<RectTransform>()) {
await TaskX.WaitTillNextFrame();
LayoutRebuilder.MarkLayoutForRebuild(go.GetComponent<RectTransform>());
await TaskX.WaitTillNextFrame();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
"name": "Vatsal Ambastha",
"email": "adrenak_@outlook.com",
"url": "http://www.vatsalambastha.com"
},
"dependencies": {}
}
}
File renamed without changes.

This file was deleted.

This file was deleted.

0 comments on commit 963451d

Please sign in to comment.