com.soosvet_games.common_tools 1.0.3 → 1.0.5

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
@@ -1,11 +1,12 @@
1
1
  #if UNITY_EDITOR
2
2
  using System.IO;
3
+ using System.Linq;
3
4
  using UnityEditor;
4
5
  using UnityEngine;
5
6
 
6
- namespace SoosvetGames.CommonTools.Extensions
7
+ namespace SoosvetGames.CommonTools
7
8
  {
8
- public static class AssetDatabaseExtensions
9
+ public static class AssetDatabaseUtils
9
10
  {
10
11
  public static void ClearFolder( this DefaultAsset defaultAsset )
11
12
  {
@@ -26,6 +27,18 @@ namespace SoosvetGames.CommonTools.Extensions
26
27
 
27
28
  AssetDatabase.Refresh();
28
29
  }
30
+
31
+ public static T LoadAsset< T >() where T : ScriptableObject
32
+ {
33
+ return LoadAssets< T >().FirstOrDefault();
34
+ }
35
+
36
+ public static T[] LoadAssets< T >( bool orderByName = true ) where T : ScriptableObject
37
+ {
38
+ var result = AssetDatabase.FindAssets( $"t:{typeof(T).Name}" ).Select( ( guid ) => AssetDatabase.LoadAssetAtPath< T >( AssetDatabase.GUIDToAssetPath( guid ) ) );
39
+
40
+ return orderByName ? result.OrderBy( ( x ) => x.name ).ToArray() : result.ToArray();
41
+ }
29
42
  }
30
43
  }
31
44
  #endif
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: a235c3cca85f17441ab13f992f59aaac
2
+ guid: 0cca5507c0b955f41b46b7ffd5ba4287
3
3
  MonoImporter:
4
4
  externalObjects: {}
5
5
  serializedVersion: 2
@@ -0,0 +1,41 @@
1
+ #if UNITY_EDITOR
2
+ using System.IO;
3
+ using System.Text;
4
+ using UnityEditor;
5
+
6
+ namespace SoosvetGames.CommonTools
7
+ {
8
+ public static class ScriptUtils
9
+ {
10
+ public static void Create(
11
+ string path,
12
+ string namespaceName,
13
+ string className,
14
+ string content
15
+ )
16
+ {
17
+ var file = CreateCustomClass( namespaceName, className, content );
18
+ var fullPath = path + $"/{className}.cs";
19
+
20
+ File.WriteAllText( fullPath, file );
21
+ AssetDatabase.ImportAsset( fullPath );
22
+ }
23
+
24
+ private static string CreateCustomClass( string namespaceName, string className, string content )
25
+ {
26
+ StringBuilder builder = new();
27
+ builder.AppendLine( $"namespace {namespaceName}" );
28
+ builder.AppendLine( "{" );
29
+ builder.Append( "\t" ).AppendLine( $"public sealed class {className}" );
30
+ builder.Append( "\t" ).AppendLine( "{" );
31
+
32
+ builder.Append( content );
33
+
34
+ builder.Append( "\t" ).AppendLine( "}" );
35
+ builder.AppendLine( "}" );
36
+
37
+ return builder.ToString();
38
+ }
39
+ }
40
+ }
41
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: a0678828fabaea847bf9203379286fc6
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 8938eb3c9af05ac448864f128e4bdb06
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
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.3",
4
+ "version" : "1.0.5",
5
5
  "author" : "Soosvet Games",
6
6
  "description" : "Common tools for Unity.",
7
7
  "repository": {