Skip to content

Commit

Permalink
- Fix ItemManager error on editor start.
Browse files Browse the repository at this point in the history
- Fix Rigidbody moving lag problem.
- Add config for skylight's shadow.
  • Loading branch information
wojiuxuihuan committed Mar 29, 2023
1 parent 6785110 commit 7bb5d80
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [3.5.0]
- Fix ItemManager error on editor start.
- Fix Rigidbody moving lag problem.
- Add config for skylight's shadow.

## [3.4.0]
- Add AC_ImagePlayer for external image or gif files.
- Add support for Mod's Run&Build.
Expand Down
2 changes: 1 addition & 1 deletion ProjectConfig~/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"dependencies": {
"com.threeyes.alivecursor.sdk": "3.4.0",
"com.threeyes.alivecursor.sdk": "3.5.0",
"com.unity.demoteam.hair": "https://github.com/Unity-Technologies/com.unity.demoteam.hair.git#0.10.0-exp.1",
"com.beans.deform": "1.2.1",
"com.coffee.ui-effect": "4.0.0-preview.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class AC_CursorStateBehaviourCollection : AC_BehaviourCollectionBase<AC_S
[Foldout(foldoutName_ActionTarget)] public GameObject actionTargetWorkingState;
[Foldout(foldoutName_ActionTarget)] public GameObject actionTargetStandByState;
[Foldout(foldoutName_ActionTarget)] public GameObject actionTargetBoredState;
[Foldout(foldoutName_ActionTarget)] public GameObject actionTargetVanishState;

//Triggered when the target CursorState enter/exit
[Foldout(foldoutName_UnityEvent)] public BoolEvent onEnterStateEnterExit;
Expand All @@ -24,6 +25,8 @@ public class AC_CursorStateBehaviourCollection : AC_BehaviourCollectionBase<AC_S
[Foldout(foldoutName_UnityEvent)] public BoolEvent onWorkingStateEnterExit;
[Foldout(foldoutName_UnityEvent)] public BoolEvent onStandByStateEnterExit;
[Foldout(foldoutName_UnityEvent)] public BoolEvent onBoredStateEnterExit;
[Foldout(foldoutName_UnityEvent)] public BoolEvent onVanishStateEnterExit;

#endregion

#region Callback
Expand All @@ -41,6 +44,9 @@ public void OnCursorStateChanged(AC_CursorStateInfo cursorStateInfo)
case AC_CursorState.StandBy: InvokeBehaviour(actionTargetStandByState, cursorStateInfo, onStandByStateEnterExit); break;
case AC_CursorState.Bored: InvokeBehaviour(actionTargetBoredState, cursorStateInfo, onBoredStateEnterExit); break;
}

bool isVanishState = AC_ManagerHolder.StateManager.IsVanishState(curCursorState);
onVanishStateEnterExit.Invoke(isVanishState);
}
#endregion

Expand Down Expand Up @@ -68,6 +74,7 @@ protected virtual void InvokeBehaviour(GameObject goTarget, AC_CursorStateInfo c
else if (stateChange == StateChange.Exit)
boolEvent.Invoke(false);
}

#endregion

#region Editor Method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class AC_TransformControllerBase<TSOConfig, TConfig> : AC_Config
public Transform CursorTransform { get { return cursorTransform; } }
protected Transform cursorTransform;//Cursor's transform

protected float deltaTime { get { return CursorRigidbody ? Time.fixedDeltaTime : Time.deltaTime; } }
protected float deltaTime { get { return/* CursorRigidbody ? Time.fixedDeltaTime : */Time.deltaTime; } }
protected Vector3 SystemCursorPosition { get { return AC_ManagerHolder.SystemCursorManager.WorldPosition; } }

#region Callback
Expand Down Expand Up @@ -73,16 +73,17 @@ public virtual void UpdateFunc()
if (!CurAliveCursor)
return;

if (!cursorRigidbody)
UpdateMovement();
//if (!cursorRigidbody)
UpdateMovement();
}
public virtual void FixedUpdateFunc()
{
if (!CurAliveCursor)
return;
//ToDelete:会导致跟随系统光标延迟的问题,统一改为移动Transform组件
//if (!CurAliveCursor)
// return;

if (cursorRigidbody)
UpdateMovement();
//if (cursorRigidbody)
// UpdateMovement();
}
public abstract void UpdateMovement();
public virtual void Teleport(Vector3 position)
Expand All @@ -98,17 +99,17 @@ public virtual void SetLocalScale(float size, Vector3 unitScale)
protected virtual void UpdateCursorPosition(Vector3 value)
{
//根据物体有无Rigidbody,调用对应方法
if (cursorRigidbody)
cursorRigidbody.MovePosition(value);
else if (cursorTransform)
cursorTransform.position = value;
//if (cursorRigidbody)
// cursorRigidbody.MovePosition(value);
//else if (cursorTransform)
cursorTransform.position = value;
}
protected virtual void UpdateCursorRotation(Quaternion value)
{
if (cursorRigidbody)
cursorRigidbody.MoveRotation(value);
else
cursorTransform.rotation = value;
//if (cursorRigidbody)
// cursorRigidbody.MoveRotation(value);
//else
cursorTransform.rotation = value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public override void SetLights(bool isUse)
sunSourceLight.transform.eulerAngles = Config.sunLightRotation;
sunSourceLight.intensity = Config.sunLightIntensity;
sunSourceLight.color = Config.sunLightColor;
sunSourceLight.shadows = Config.lightShadowType;
}
}
base.SetLights(isUse);
Expand Down Expand Up @@ -216,6 +217,7 @@ public class ConfigInfo : AC_SerializableDataBase
[EnableIf(nameof(isUseLights))] [AllowNesting] public Vector3 sunLightRotation = new Vector3(30, 30, 240);
[EnableIf(nameof(isUseLights))] [AllowNesting] [Range(0, 8)] public float sunLightIntensity = 0.3f;
[EnableIf(nameof(isUseLights))] [AllowNesting] public Color sunLightColor = Color.white;
[EnableIf(nameof(isUseLights))] public LightShadows lightShadowType = LightShadows.None;

[Header("ReflectionProbe")]
[PersistentValueChanged(nameof(OnPersistentValueChanged_IsUseReflection))] public bool isUseReflection = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public class AC_StateManagerBase<T> : AC_ManagerWithControllerBase<T, IAC_StateC
public AC_CursorStateInfo CurCursorStateInfo { get { return curCursorStateInfo; } }
public AC_CursorState CurCursorState { get { return curCursorState; } }//单独以字段保存,而不是从curCursorStateInfo中获取,避免空引用或引用被修改
public AC_CursorState LastCursorState { get { return lastCursorState; } }

public bool IsVanishState(AC_CursorState cursorState)
{
return cursorState == AC_CursorState.Exit || cursorState == AC_CursorState.Hide || cursorState == AC_CursorState.StandBy;
}
public bool IsCurStateActionComplete(ActionState actionState)
{
return ActiveController.IsCurStateActionComplete(actionState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public virtual Vector3 WorldPosition
return GetWorldPosition(curDepth);
}
}
public Vector3 MousePosition { get { return Input.mousePosition; } }////与new InputSystem Mouse.current.position.ReadValue结果相同
public virtual Vector3 MousePosition { get { return Input.mousePosition; } }////与new InputSystem Mouse.current.position.ReadValue结果相同
public float CurDepth { get { return curDepth; } set { curDepth = value; } }
public float WorkingStateCameraDepth { get { return 10f; } }//光标在Woring状态时相对相机的深度
public Vector2 BoredStateCameraDepthRange { get { return new Vector2(WorkingStateCameraDepth, WorkingStateCameraDepth + commonSetting_BoredDepth); } }//光标在Bored状态时相对相机的深度范围
Expand All @@ -54,7 +54,9 @@ public bool IsInsideBoredBounds(Vector3 worldPosition)
}
public Vector3 GetWorldPosition(float depth)//使用自定义深度
{
return MainCamera.ScreenToWorldPoint(new Vector3(MousePosition.x, MousePosition.y, depth));
Vector3 worldPos = MousePosition;
worldPos.z = depth;
return MainCamera.ScreenToWorldPoint(worldPos);
}
/// <summary>
/// 检查指定体积的物体是否在相机视野内
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ public interface IAC_StateManager : IAC_Manager_ModInitHandler, IManagerWithCont
AC_CursorState CurCursorState { get; }
AC_CursorState LastCursorState { get; }

/// <summary>
/// Check if AC is vanished in specify state (Exit、Hide、StandBy)
/// </summary>
/// <param name="cursorState"></param>
/// <returns></returns>
bool IsVanishState(AC_CursorState cursorState);
/// <summary>
/// Check if target ActionState Completed
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Threeyes/SDK/Scripts/Editor/AC_ItemManagerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ private void OnEnable()
buttonEditScene.RegisterCallback<ClickEvent>(OnEditSceneButtonClick);

textFieldExePath = rootVisualElement.Q<TextField>("ExePathTextField");
textFieldExePath.RegisterCallback<ChangeEvent<string>>(OnExePathTextFieldChanged);
textFieldExePath.value = SOManagerInst.ItemWindow_ExePath;
textFieldExePath.RegisterCallback<ChangeEvent<string>>(OnExePathTextFieldChanged);
buttonSelectExe = rootVisualElement.Q<Button>("SelectExeButton");
buttonSelectExe.RegisterCallback<ClickEvent>(OnSelectExeButtonClick);
buttonItemBuild = rootVisualElement.Q<Button>("ItemBuildButton");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ MonoBehaviour:
m_RotationOrder: 4
reachThreshold: 0.05
isFixedAngle: 1
workingAngle: 0
workingAngle: 30
boredMovementConfig:
moveSpeed: 1
rotateSpeed: 3
Expand Down
4 changes: 2 additions & 2 deletions UMod/Resources/Editor/ModToolsSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ MonoBehaviour:
toolsIconSmall: {fileID: 2800000, guid: 1766a127aff47554495b1d5616382819, type: 3}
toolsIconLarge: {fileID: 2800000, guid: 1766a127aff47554495b1d5616382819, type: 3}
toolsName: AliveCursorSDK
toolsVersion: 3.4.0
toolsVersion: 3.5.0
firstRunWindow:
assemblyQualifiedName:
developerName: Threeyes
syncDeveloperName: 0
gameName: AliveCursor
syncGameName: 0
gameVersion: 3.4.0
gameVersion: 3.5.0
syncGameVersion: 1
modFileExtension: .umod
commandLineLaunchFormat: +mod=$PATH
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.threeyes.alivecursor.sdk",
"displayName": "AliveCursorSDK",
"version": "3.4.0",
"version": "3.5.0",
"unity": "2021.3",
"description": "SDK for AliveCursor.",
"documentationUrl": "https://github.com/Threeyes/AliveCursorSDK/wiki",
Expand Down

0 comments on commit 7bb5d80

Please sign in to comment.