com.soosvet_games.common_tools 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ using System;
2
+
3
+ namespace SoosvetGames.CommonTools
4
+ {
5
+ public interface IObservable
6
+ {
7
+ event Action OnChanged;
8
+ }
9
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 5f9e8cdf54074586b48bf90f3c001a81
3
+ timeCreated: 1785824150
@@ -0,0 +1,7 @@
1
+ namespace SoosvetGames.CommonTools
2
+ {
3
+ public interface IReadOnly< T > : IObservable
4
+ {
5
+ T Value { get; }
6
+ }
7
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: ae82d1bd7fa244a29b4115e23915f5fa
3
+ timeCreated: 1785824180
@@ -0,0 +1,7 @@
1
+ namespace SoosvetGames.CommonTools
2
+ {
3
+ public interface IValue< T > : IReadOnly< T >
4
+ {
5
+ new T Value { get; set; }
6
+ }
7
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: db42f7737c1a448e8ea3a9737a75fe9c
3
+ timeCreated: 1785824200
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: cde3f856644d4151a6460c3851c7095a
3
+ timeCreated: 1785824139
@@ -0,0 +1,54 @@
1
+ using System.Collections.Generic;
2
+ using UnityEngine;
3
+
4
+ namespace SoosvetGames.CommonTools.Extensions
5
+ {
6
+ public static class TransformExtensions
7
+ {
8
+ public static void DestroyChildren( this Transform transform, bool isImmediate = false )
9
+ {
10
+ if ( transform == null ) return;
11
+
12
+ for ( int i = transform.childCount - 1; i >= 0; i-- )
13
+ {
14
+ Transform child;
15
+ try
16
+ {
17
+ child = transform.GetChild( i );
18
+ }
19
+ catch
20
+ {
21
+ continue;
22
+ }
23
+
24
+ if ( !child ) continue;
25
+
26
+ if ( isImmediate )
27
+ {
28
+ Object.DestroyImmediate( child.gameObject );
29
+ }
30
+ else
31
+ {
32
+ Object.Destroy( child.gameObject );
33
+ }
34
+ }
35
+ }
36
+
37
+ public static IEnumerable< Transform > GetChildren( this Transform transform )
38
+ {
39
+ var i = 0;
40
+
41
+ while ( i < transform.childCount )
42
+ {
43
+ yield return transform.GetChild( i );
44
+ ++i;
45
+ }
46
+ }
47
+
48
+ public static T GetOrAddComponent< T >( this GameObject gameObject ) where T : Component
49
+ {
50
+ var result = gameObject.GetComponent< T >();
51
+ return result == null ? gameObject.AddComponent< T >() : result;
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 7775f7414d2e4802a9f9fc5be0ec9d1f
3
+ timeCreated: 1785769930
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name" : "com.soosvet_games.common_tools",
3
3
  "displayName" : "Soosvet Games Common Tools",
4
- "version" : "1.0.2",
4
+ "version" : "1.0.4",
5
5
  "author" : "Soosvet Games",
6
6
  "description" : "Common tools for Unity.",
7
7
  "repository": {