mirror of
https://github.com/nothke/quality-control.git
synced 2025-08-08 23:03:43 +00:00
Merge branch 'master' of https://github.com/nothke/quality-control
This commit is contained in:
@@ -4,24 +4,36 @@ using UnityEngine;
|
||||
|
||||
public class ConveyorBelt : MonoBehaviour
|
||||
{
|
||||
Rigidbody _rb;
|
||||
Rigidbody rb { get { if (!_rb) _rb = GetComponent<Rigidbody>(); return _rb; } }
|
||||
|
||||
public float speed = 1;
|
||||
|
||||
List<ContactPoint> contactPoints = new List<ContactPoint>();
|
||||
Vector3 startPosition;
|
||||
|
||||
private void OnCollisionStay(Collision collision)
|
||||
float scrollingTextureProgress = 0;
|
||||
public float scrollingTextureSpeedMult = 1;
|
||||
public Renderer scrollingTextureRenderer;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Vector3 targetSpeed = speed * Vector3.forward;
|
||||
startPosition = rb.position;
|
||||
}
|
||||
|
||||
Vector3 vel = collision.relativeVelocity;
|
||||
private void FixedUpdate()
|
||||
{
|
||||
rb.position = startPosition;
|
||||
Vector3 targetSpeed = speed * transform.forward;
|
||||
rb.MovePosition(rb.position + targetSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
int count = collision.GetContacts(contactPoints);
|
||||
|
||||
if (collision.rigidbody)
|
||||
private void Update()
|
||||
{
|
||||
if(scrollingTextureRenderer)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
|
||||
}
|
||||
scrollingTextureProgress += Time.deltaTime * speed * scrollingTextureSpeedMult;
|
||||
scrollingTextureRenderer.material.SetTextureOffset("_MainTex",
|
||||
new Vector2(0, scrollingTextureProgress));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
8
Assets/Scripts/Editor.meta
Normal file
8
Assets/Scripts/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51fc89590d392e4458728c087b430687
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
12
Assets/Scripts/Editor/TexturePreprocessor.cs
Normal file
12
Assets/Scripts/Editor/TexturePreprocessor.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
class TexturePreprocessor : AssetPostprocessor
|
||||
{
|
||||
void OnPreprocessTexture()
|
||||
{
|
||||
// if (assetPath.Contains("_bumpmap"))
|
||||
TextureImporter textureImporter = (TextureImporter)assetImporter;
|
||||
textureImporter.filterMode = FilterMode.Point;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Editor/TexturePreprocessor.cs.meta
Normal file
11
Assets/Scripts/Editor/TexturePreprocessor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d33006e1540e5a649b300c3c7954e1f3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
44
Assets/Scripts/WeightDetector.cs
Normal file
44
Assets/Scripts/WeightDetector.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WeightDetector : MonoBehaviour
|
||||
{
|
||||
HashSet<Rigidbody> enteredBodies = new HashSet<Rigidbody>();
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
var rb = collision.rigidbody;
|
||||
|
||||
if (rb)
|
||||
{
|
||||
enteredBodies.Add(rb);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionExit(Collision collision)
|
||||
{
|
||||
var rb = collision.rigidbody;
|
||||
|
||||
if (rb)
|
||||
{
|
||||
enteredBodies.Remove(rb);
|
||||
}
|
||||
}
|
||||
|
||||
public float GetTotalWeight()
|
||||
{
|
||||
float totalMass = 0;
|
||||
foreach (var body in enteredBodies)
|
||||
{
|
||||
totalMass += body.mass;
|
||||
}
|
||||
|
||||
return totalMass;
|
||||
}
|
||||
|
||||
//private void Update()
|
||||
//{
|
||||
// Debug.Log(GetTotalWeight());
|
||||
//}
|
||||
}
|
11
Assets/Scripts/WeightDetector.cs.meta
Normal file
11
Assets/Scripts/WeightDetector.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f935fa08cd417994097c7b59d2547f0d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user