Skip to content

Commit c48492f

Browse files
committed
Improvements on Property structure
0 parents  commit c48492f

74 files changed

Lines changed: 4410 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.icon.png

6.3 KB
Loading

Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "GameWorkstore.Patterns.Editor",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:c32d36751e998d74999be5c29b033d6e"
6+
],
7+
"includePlatforms": [
8+
"Editor"
9+
],
10+
"excludePlatforms": [],
11+
"allowUnsafeCode": false,
12+
"overrideReferences": false,
13+
"precompiledReferences": [],
14+
"autoReferenced": true,
15+
"defineConstraints": [],
16+
"versionDefines": [],
17+
"noEngineReferences": false
18+
}

Editor/GameWorkstore.Patterns.Editor.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using UnityEngine;
2+
using UnityEditor;
3+
4+
namespace GameWorkstore.Patterns.Editor
5+
{
6+
[CustomPropertyDrawer(typeof(SceneAssetPath))]
7+
public class SceneAssetPathPropertyDrawer : PropertyDrawer
8+
{
9+
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
10+
{
11+
var propertyScene = property.FindPropertyRelative("Scene");
12+
var oldScene = AssetDatabase.LoadAssetAtPath<SceneAsset>(propertyScene.stringValue);
13+
return oldScene ? 20 : 60;
14+
}
15+
16+
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
17+
{
18+
19+
var propertyScene = property.FindPropertyRelative("Scene");
20+
var propertyGuid = property.FindPropertyRelative("Guid");
21+
22+
var oldScene = AssetDatabase.LoadAssetAtPath<SceneAsset>(propertyScene.stringValue);
23+
if (!oldScene)
24+
{
25+
var path = AssetDatabase.GUIDToAssetPath(propertyGuid.stringValue);
26+
if (!string.IsNullOrEmpty(path))
27+
{
28+
oldScene = AssetDatabase.LoadAssetAtPath<SceneAsset>(path);
29+
}
30+
}
31+
32+
EditorGUI.BeginChangeCheck();
33+
34+
var rt1 = position;
35+
rt1.size = new Vector2(position.size.x, 20);
36+
var newScene = EditorGUI.ObjectField(rt1, "Scene", oldScene, typeof(SceneAsset), false) as SceneAsset;
37+
if (!newScene)
38+
{
39+
position.position += new Vector2(0, rt1.size.y);
40+
var rt2 = position;
41+
rt2.size = new Vector2(position.size.x, 40);
42+
EditorGUI.HelpBox(rt2, "SceneAssets are weak references. To ensure consistency when moving scenes, declare OnValidate() function on MonoBehaviour parent and call the OnValidate() of this variable to ensure consistenty by GUID.", MessageType.Info);
43+
}
44+
if (!EditorGUI.EndChangeCheck()) return;
45+
var newPath = AssetDatabase.GetAssetPath(newScene);
46+
propertyScene.stringValue = newPath;
47+
propertyGuid.stringValue = AssetDatabase.AssetPathToGUID(newPath);
48+
}
49+
}
50+
}

Editor/SceneAssetPathPropertyDrawer.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
MIT License
2+
3+
Copyright (c) 2015, Unity Technologies
4+
5+
Copyright (c) 2020 Game Workstore
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.

LICENSE.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Patterns
2+
GameWorkstore basic pattern structures and project helpers
3+
Use it your own risk!
4+
5+
# How to install
6+
7+
At package.json, add these lines of code:
8+
```json
9+
"com.gameworkstore.patterns": "https://github.com/GameWorkstore/patterns.git#1.1.2"
10+
```
11+
12+
And wait for unity to download and compile the package.
13+
14+
you can upgrade your version by including the release version at end of the link:
15+
```json
16+
"com.gameworkstore.patterns": "https://github.com/GameWorkstore/patterns.git#1.2.0"
17+
```
18+
19+
# Contributions
20+
21+
If you are using this library and want to submit a change, go ahead! Overall, this project accepts contributions if:
22+
- Is a bug fix;
23+
- Or, is a generalization of a well-known issue;
24+
- Or is performance improvement;
25+
- Or is an improvement to already supported feature.
26+
27+
Also, you can donate to allow us to drink coffee while we improve it for you!

README.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)