This commit is contained in:
2020-08-01 17:55:18 +08:00
parent 29a8a1dae3
commit 4435098171
160 changed files with 21247 additions and 2405 deletions

View File

@@ -93,7 +93,7 @@ public class UIScrollView : MonoBehaviour
/// Strength of the spring dampening effect.
/// </summary>
public float dampenStrength = 9f;
public float dampenStrength = 5f;
/// <summary>
/// Horizontal scrollbar used for visualization.
@@ -850,26 +850,26 @@ public class UIScrollView : MonoBehaviour
// Adjust the momentum
if (dragEffect == DragEffect.None) mMomentum = Vector3.zero;
else mMomentum = Vector3.Lerp(mMomentum, mMomentum + offset * (0.01f * momentumAmount), 0.67f);
else mMomentum = Vector3.Lerp(mMomentum, mMomentum + offset * (0.02f * momentumAmount), 0.67f);
// Move the scroll view
if (!iOSDragEmulation || dragEffect != DragEffect.MomentumAndSpring)
{
MoveAbsolute(offset);
}
MoveAbsolute(offset);
}
else
{
Vector3 constraint = mPanel.CalculateConstrainOffset(bounds.min, bounds.max);
if (constraint.magnitude > 1f)
{
MoveAbsolute(offset * 0.5f);
mMomentum *= 0.5f;
MoveAbsolute(offset * 0.5f);
mMomentum *= 0.5f;
}
else
{
MoveAbsolute(offset);
}
MoveAbsolute(offset);
}
}
// We want to constrain the UI to be within bounds
@@ -877,10 +877,11 @@ public class UIScrollView : MonoBehaviour
mPanel.clipping != UIDrawCall.Clipping.None &&
dragEffect != DragEffect.MomentumAndSpring)
{
InvalidateBounds();
RestrictWithinBounds(true, canMoveHorizontally, canMoveVertically);
}
if (onDragmMove != null)
if (onDragmMove != null)
onDragmMove();
}
}
@@ -908,7 +909,8 @@ public class UIScrollView : MonoBehaviour
/// Apply the dragging momentum.
/// </summary>
void LateUpdate ()
//void LateUpdate()
void Update ()
{
if (!Application.isPlaying) return;
float delta = RealTime.deltaTime;
@@ -949,25 +951,27 @@ public class UIScrollView : MonoBehaviour
{
if (mMomentum.magnitude > 0.0001f || mScroll != 0f)
{
float factor = 0.01f; // 0.05f
if (movement == Movement.Horizontal)
{
mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * 0.05f, 0f, 0f));
mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * factor, 0f, 0f));
}
else if (movement == Movement.Vertical)
{
mMomentum -= mTrans.TransformDirection(new Vector3(0f, mScroll * 0.05f, 0f));
mMomentum -= mTrans.TransformDirection(new Vector3(0f, mScroll * factor, 0f));
}
else if (movement == Movement.Unrestricted)
{
mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * 0.05f, mScroll * 0.05f, 0f));
mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * factor, mScroll * factor, 0f));
}
else
{
mMomentum -= mTrans.TransformDirection(new Vector3(
mScroll * customMovement.x * 0.05f,
mScroll * customMovement.y * 0.05f, 0f));
mScroll * customMovement.x * factor,
mScroll * customMovement.y * factor, 0f));
}
mScroll = NGUIMath.SpringLerp(mScroll, 0f, 20f, delta);
//mScroll = NGUIMath.SpringLerp(mScroll, 0f, 20f, delta);
mScroll = NGUIMath.SpringLerp(mScroll, 0f, 5f, delta);
// Move the scroll view
Vector3 offset = NGUIMath.SpringDampen(ref mMomentum, dampenStrength, delta);
@@ -987,7 +991,8 @@ public class UIScrollView : MonoBehaviour
}
else
{
RestrictWithinBounds(false, canMoveHorizontally, canMoveVertically);
InvalidateBounds();
RestrictWithinBounds(true, canMoveHorizontally, canMoveVertically);
}
}
@@ -1005,6 +1010,27 @@ public class UIScrollView : MonoBehaviour
mShouldMove = false;
if (onStoppedMoving != null)
onStoppedMoving();
/*
// Restrict the contents to be within the scroll view's bounds
if (restrictWithinPanel && mPanel.clipping != UIDrawCall.Clipping.None)
{
if (NGUITools.GetActive(centerOnChild))
{
if (centerOnChild.nextPageThreshold != 0f)
{
mMomentum = Vector3.zero;
mScroll = 0f;
}
else centerOnChild.Recenter();
}
else
{
InvalidateBounds();
RestrictWithinBounds(false, canMoveHorizontally, canMoveVertically);
}
}
*/
}
}
else

View File

@@ -427,15 +427,15 @@ namespace Coolape
}
}
public static UnityWebRequest put(string url, string data, CLAssetType type,
public static UnityWebRequest put(string url, object header, string data, CLAssetType type,
object successCallback,
object failedCallback, object orgs,
bool isCheckTimeout = true, int maxFailTimes = 1)
{
return _put(url, data, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, 0);
return _put(url, header, data, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, 0);
}
private static UnityWebRequest _put(string url, string data, CLAssetType type,
private static UnityWebRequest _put(string url, object header, string data, CLAssetType type,
object successCallback,
object failedCallback, object orgs, bool isCheckTimeout,
int maxFailTimes, int failedTimes)
@@ -447,11 +447,12 @@ namespace Coolape
return null;
self.enabled = true;
UnityWebRequest www = UnityWebRequest.Put(url, data);
setWWWHeader(www, header);
Coroutine cor = self.StartCoroutine(
self.exeWWW(www, url, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, failedTimes,
(url2) =>
{
_put(url2, data, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, failedTimes + 1);
_put(url2, header ,data, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, failedTimes + 1);
}));
wwwMap4Get[url] = cor;
return www;
@@ -464,16 +465,16 @@ namespace Coolape
}
}
public static UnityWebRequest put(string url, byte[] data, CLAssetType type,
public static UnityWebRequest put(string url, object header, byte[] data, CLAssetType type,
object successCallback,
object failedCallback, object orgs, bool isCheckTimeout = true, int maxFailTimes = 1)
{
return _put(url, data, type,
return _put(url, header, data, type,
successCallback,
failedCallback, orgs, isCheckTimeout,
maxFailTimes, 0);
}
private static UnityWebRequest _put(string url, byte[] data, CLAssetType type,
private static UnityWebRequest _put(string url, object header, byte[] data, CLAssetType type,
object successCallback,
object failedCallback, object orgs, bool isCheckTimeout,
int maxFailTimes, int failedTimes)
@@ -484,11 +485,12 @@ namespace Coolape
return null;
self.enabled = true;
UnityWebRequest www = UnityWebRequest.Put(url, data);
setWWWHeader(www, header);
Coroutine cor = self.StartCoroutine(
self.exeWWW(www, url, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, failedTimes,
(url2) =>
{
_put(url2, data, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, failedTimes + 1);
_put(url2, header, data, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, failedTimes + 1);
}));
wwwMap4Get[url] = cor;
return www;
@@ -517,11 +519,18 @@ namespace Coolape
public static UnityWebRequest uploadFile(string url, string sectionName, string fileName, byte[] fileContent, CLAssetType type,
object successCallback, object failedCallback, object orgs, bool isCheckTimeout = true, int maxFailTimes = 1)
{
return _uploadFile(url, sectionName, fileName, fileContent, type,
return _uploadFile(url, null, sectionName, fileName, fileContent, type,
successCallback, failedCallback, orgs, isCheckTimeout,
maxFailTimes, 0);
}
private static UnityWebRequest _uploadFile(string url, string sectionName, string fileName, byte[] fileContent, CLAssetType type,
public static UnityWebRequest uploadFile(string url, object header, string sectionName, string fileName, byte[] fileContent, CLAssetType type,
object successCallback, object failedCallback, object orgs, bool isCheckTimeout = true, int maxFailTimes = 1)
{
return _uploadFile(url,header, sectionName, fileName, fileContent, type,
successCallback, failedCallback, orgs, isCheckTimeout,
maxFailTimes, 0);
}
private static UnityWebRequest _uploadFile(string url, object header, string sectionName, string fileName, byte[] fileContent, CLAssetType type,
object successCallback, object failedCallback, object orgs, bool isCheckTimeout,
int maxFailTimes, int failedTimes)
{
@@ -534,11 +543,12 @@ namespace Coolape
List<IMultipartFormSection> multForom = new List<IMultipartFormSection>();
multForom.Add(fileSection);
UnityWebRequest www = UnityWebRequest.Post(url, multForom);
setWWWHeader(www, header);
Coroutine cor = self.StartCoroutine(
self.exeWWW(www, url, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, failedTimes,
(url2) =>
{
_uploadFile(url2, sectionName, fileName, fileContent, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, failedTimes + 1);
_uploadFile(url2, header, sectionName, fileName, fileContent, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, failedTimes + 1);
}));
wwwMap4Get[url] = cor;
return www;

View File

@@ -70,8 +70,9 @@ namespace Coolape
}
if (panel != null) {
oldClipOffset = panel.clipOffset;
panel.cullWhileDragging = true;
panel.onClipMove = OnMove;
}
panel.cullWhileDragging = true;
}
}
return _scrollView;
@@ -445,6 +446,10 @@ namespace Coolape
isCanCallOnEndList = true;
isCanCallOnHeadList = true;
if(list.Count == 0)
{
ExecuteOnShowHeadList();
}
} catch (System.Exception e) {
Debug.LogError (e);
}
@@ -575,6 +580,27 @@ namespace Coolape
}
}
}
protected virtual void OnMove(UIPanel panel)
{
if (scrollView == null) return;
bool restrictWithinPanel = false;
if (list == null || list.Count == 0)
{
restrictWithinPanel = true;
}
if (!restrictWithinPanel && firstVislable && int.Parse(head.name) == 0)
{
restrictWithinPanel = true;
}
if (!restrictWithinPanel && lastVisiable && int.Parse(tail.name) == list.Count - 1)
{
restrictWithinPanel = true;
}
scrollView.restrictWithinPanel = restrictWithinPanel;
}
// 从原顺序位置移动到指定位置
void moveCellPos (UIWidget moved, UIWidget target, int newIdx, int targetIdx)
{

View File

@@ -50,6 +50,7 @@ namespace Coolape
oldScrollViewPos = _scrollView.transform.localPosition;
oldClipOffset = _scrollView.panel.clipOffset;
_scrollView.panel.cullWhileDragging = true;
_scrollView.panel.onClipMove = OnMove;
}
}
return _scrollView;
@@ -703,5 +704,25 @@ namespace Coolape
itemList.Insert (targetIndex, movedWidget);
}
}
protected virtual void OnMove(UIPanel panel)
{
if (scrollView == null) return;
bool restrictWithinPanel = false;
if (list == null || list.Count == 0)
{
restrictWithinPanel = true;
}
if (!restrictWithinPanel && firstVislable && int.Parse(head.name) == 0)
{
restrictWithinPanel = true;
}
if (!restrictWithinPanel && lastVisiable && int.Parse(tail.name) == list.Count - 1)
{
restrictWithinPanel = true;
}
scrollView.restrictWithinPanel = restrictWithinPanel;
}
}
}
}

View File

@@ -100,9 +100,11 @@ public class CLUIScrollViewWithEvent : UIScrollView
if (movement == Movement.Vertical && totalDelta.y <= 0)
{
ResetPosition();
//RestrictWithinBounds(false);
} else if (movement == Movement.Horizontal && totalDelta.x >= 0)
{
//RestrictWithinBounds(false);
ResetPosition();
}
}
}