Skip to content

Commit

Permalink
- Fix Joints using AC_RigBuilderHelper will be misplaced when cursor …
Browse files Browse the repository at this point in the history
…reactive.

- Update Facepunch.Steamworks.
  • Loading branch information
wojiuxuihuan committed Aug 27, 2023
1 parent 2669b6c commit 13f692e
Show file tree
Hide file tree
Showing 61 changed files with 975 additions and 340 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [4.0.2]
- Fix Joints using AC_RigBuilderHelper will be misplaced when cursor reactive.
- Update Facepunch.Steamworks.

## [4.0.1]
- Update Facepunch.Steamworks.
- Mod Scripts improvement.
Expand Down
2 changes: 1 addition & 1 deletion ProjectConfig~/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"com.threeyes.alivecursor.sdk": "4.0.1",
"com.threeyes.alivecursor.sdk": "4.0.2",
"com.unity.demoteam.hair": "https://github.com/Unity-Technologies/com.unity.demoteam.hair.git#0.10.0-exp.1",
"com.coffee.ui-effect": "4.0.0-preview.9",
"com.beans.deform": "1.2.1",
Expand Down
Binary file not shown.
Binary file not shown.

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.

Binary file not shown.
Binary file not shown.

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.

Binary file not shown.
Binary file not shown.

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.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public TData CurData
{
get
{
if (CurIndex > 0 && CurIndex < ListData.Count)
if (CurIndex >= 0 && CurIndex < ListData.Count)
{
return ListData[CurIndex];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,17 @@ public static void Recursive<T>(this T em, UnityAction<T> action, Func<T, IEnume
tfInst.rotation = rotation;
}
}
/// <summary>
/// 销毁游戏对象,同时避免Destroy延迟销毁影响后续子物体层级查询
/// </summary>
/// <param name="tf"></param>
public static void DestroyAtOnce(this GameObject go)
{
if (go.transform.parent)
go.transform.SetParent(null);

Destroy(go.transform);
}
#endregion

#region Transform
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
Expand Down Expand Up @@ -96,6 +96,20 @@ public static void SetPivotAndAnchors(this RectTransform trans, Vector2 aVec)
trans.anchorMax = aVec;
}

/// <summary>
/// 获取RectTransform中的某个位置
/// </summary>
/// <param name="trans"></param>
/// <param name="screenPoint">像素坐标,如mousePosition</param>
/// <param name="camera">Canvas对应的相机。针对Overlay的Cavnas,camera值必须为null,否则会报错。(Warning:If you are using a canvas in 'Screen Space - Overlay' (e.g. a 2D canvas), you have to pass null as the argument for the camera to the RectTransformUtility. If you try to pass the main camera, or any other camera in the scene, in as an argument, you will get bizarre results that seem to have no bearing on reality.)</param>
/// <returns></returns>
public static Vector2 GetPos(this RectTransform trans, Vector2 screenPoint, Camera camera = null)
{
Vector2 originalLocalPointerPosition;
RectTransformUtility.ScreenPointToLocalPointInRectangle(trans, screenPoint, camera, out originalLocalPointerPosition);
return originalLocalPointerPosition;
}

public static void SetPositionOfPivot(this RectTransform trans, Vector2 newPos)
{
trans.localPosition = new Vector3(newPos.x, newPos.y, trans.localPosition.z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "Threeyes.Plugin.Core",
"rootNamespace": "",
"references": [
"GUID:776d03a35f1b52c4a9aed9f56d7b4229"
"GUID:776d03a35f1b52c4a9aed9f56d7b4229",
"GUID:75469ad4d38634e559750d17036d5f7c"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
105 changes: 104 additions & 1 deletion Threeyes/Plugins/ThreeyesPlugin/Core/Tool/Editors/EditorTool.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_EDITOR
#if UNITY_EDITOR
using System.Linq;
using System.Reflection;
using UnityEngine;
Expand All @@ -7,6 +7,8 @@
using UnityEditorInternal;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
using System.Threading;
using System.IO;

namespace Threeyes.Editor
{
Expand All @@ -16,6 +18,107 @@ namespace Threeyes.Editor
/// </summary>
public static class EditorTool
{
#region Asset
/// <summary>
/// 重命名资源,保留引用
/// </summary>
/// <param name="obj"></param>
/// <param name="newName">新名称(不带后缀)</param>
/// <returns>An empty string, if the asset has been successfully renamed, otherwise an error
// message.</returns>
public static string Rename(Object obj, string newName)
{
var relateObjPath = AssetDatabase.GetAssetPath(obj);
return AssetDatabase.RenameAsset(relateObjPath, newName);
}

/// <summary>
/// 将指定Asset的预览图保存为资源文件,默认存储在obj所在目录的Preview Texture文件夹下
/// </summary>
/// <param name="obj">Asset文件夹中的任意文件</param>
/// <param name="overrideSavedPath">自定义预览图存储路径(包括文件名)</param>
/// <returns></returns>
public static Texture CreateAndSaveAssetPreview(Object obj, string overrideSavedPath = "")
{
if (obj == null)
{
Debug.LogError("Can't create preview for null object");
return null;
}
var relateObjPath = AssetDatabase.GetAssetPath(obj);
if (!relateObjPath.StartsWith("Assets"))
{
Debug.LogError("only support object insde Assets Folder!");
return null;
}
Texture2D preview = AssetPreview.GetAssetPreview(obj);

//wait untill unity loads preview
int tm = 0;
while (preview == null)
{
Thread.Sleep(100);
preview = AssetPreview.GetAssetPreview(obj);
tm += 100;
if (tm >= 3000) //3 sec countdown
break;
}

///出错可能原因:
///-选中的Asset在只读路径中(如package)
if (preview == null)
{
Debug.LogError($"Unable to create preview for object {obj.name}, perhaps the resource is not in the Asset folder.");
return null;
}

var relatePreviewTexturePath = relateObjPath.Substring(0, relateObjPath.LastIndexOf("/")) + "/Preview Texture";//将预览图存在obj所在目录的Preview Texture文件夹下
string savePath = Path.Combine(Application.dataPath, relatePreviewTexturePath.Replace("Assets/", string.Empty));

CreateSaveFolder(savePath);

//encode to png and then save to assets
var bytes = preview.EncodeToPNG();
string name = obj.name + ".png";
string imagePath = overrideSavedPath.NotNullOrEmpty() ? overrideSavedPath : relatePreviewTexturePath + "/" + name;


if (File.Exists(name))
File.Delete(name);
File.WriteAllBytes(imagePath, bytes);

Debug.Log("创建预览图:\r\n" + imagePath);

//refresh assets
AssetDatabase.Refresh();

//change from texture to sprite
TextureImporter importer = (TextureImporter)AssetImporter.GetAtPath(imagePath);//Assets的目录
importer.textureType = TextureImporterType.Sprite;
importer.spriteImportMode = SpriteImportMode.Single;
EditorUtility.SetDirty(importer);
AssetDatabase.ImportAsset(imagePath);
AssetDatabase.Refresh();

Texture objTex = AssetDatabase.LoadAssetAtPath<Texture>(imagePath);
return objTex;
//Selection.objects = new Object[] { objTex };
}

/// <summary>
/// [EDITOR ONLY] Check if the save directory exitst. If no creates it
/// </summary>
static void CreateSaveFolder(string savePath)
{
if (!Directory.Exists(savePath))
{
Debug.Log("Created directory: " + savePath);
Directory.CreateDirectory(savePath);
AssetDatabase.Refresh();
}
}
#endregion

#region Repaint

public static void RepaintSceneView()
Expand Down
Loading

0 comments on commit 13f692e

Please sign in to comment.