plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent ed7b223c04
commit fd87a6ffd5
14441 changed files with 13711084 additions and 20 deletions

View File

@@ -0,0 +1,129 @@
using System.Collections;
using UnityEngine;
namespace HPhysic
{
[RequireComponent (typeof (Rigidbody))]
public class Connector : MonoBehaviour
{
public ConType ConnectionType { get; private set; } = ConType.Male;
[SerializeField] private bool makeConnectionKinematic = false;
private bool _wasConnectionKinematic;
[SerializeField] private bool hideInteractableWhenIsConnected = false;
[field: SerializeField] public Connector ConnectedTo { get; private set; }
[Header ("Object to set")]
public Transform connectionPoint;
private FixedJoint _fixedJoint;
public Rigidbody Rigidbody { get; private set; }
public Vector3 ConnectionPosition => connectionPoint ? connectionPoint.position : transform.position;
public Quaternion ConnectionRotation => connectionPoint ? connectionPoint.rotation : transform.rotation;
public Quaternion RotationOffset => connectionPoint ? connectionPoint.localRotation : Quaternion.Euler (Vector3.zero);
public Vector3 ConnectedOutOffset => connectionPoint ? connectionPoint.right : transform.right;
public bool IsConnected => ConnectedTo != null;
public enum ConType { Male, Female }
private void Awake ()
{
Rigidbody = gameObject.GetComponent<Rigidbody> ();
}
private void Start ()
{
if (ConnectedTo != null) {
Connector t = ConnectedTo;
ConnectedTo = null;
Connect (t);
}
}
private void OnDisable () => Disconnect ();
public void SetAsConnectedTo (Connector secondConnector)
{
ConnectedTo = secondConnector;
_wasConnectionKinematic = secondConnector.Rigidbody.isKinematic;
UpdateInteractableWhenIsConnected ();
}
public void Connect (Connector secondConnector)
{
if (secondConnector == null) {
Debug.LogWarning ("Attempt to connect null");
return;
}
if (IsConnected) {
Disconnect (secondConnector);
}
secondConnector.transform.rotation = ConnectionRotation * secondConnector.RotationOffset;
secondConnector.transform.position = ConnectionPosition - (secondConnector.ConnectionPosition - secondConnector.transform.position);
_fixedJoint = gameObject.AddComponent<FixedJoint> ();
_fixedJoint.connectedBody = secondConnector.Rigidbody;
secondConnector.SetAsConnectedTo (this);
_wasConnectionKinematic = secondConnector.Rigidbody.isKinematic;
if (makeConnectionKinematic) {
secondConnector.Rigidbody.isKinematic = true;
}
ConnectedTo = secondConnector;
// disable outline on select
UpdateInteractableWhenIsConnected ();
}
public void Disconnect (Connector onlyThis = null)
{
if (ConnectedTo == null || onlyThis != null && onlyThis != ConnectedTo) {
return;
}
Destroy (_fixedJoint);
// important to dont make recusrion
Connector toDisconect = ConnectedTo;
ConnectedTo = null;
if (makeConnectionKinematic) {
toDisconect.Rigidbody.isKinematic = _wasConnectionKinematic;
}
toDisconect.Disconnect (this);
// enable outline on select
UpdateInteractableWhenIsConnected ();
}
private void UpdateInteractableWhenIsConnected ()
{
if (hideInteractableWhenIsConnected) {
if (TryGetComponent (out Collider collider)) {
collider.enabled = !IsConnected;
}
}
}
public bool CanConnect (Connector secondConnector) =>
this != secondConnector
&& !this.IsConnected && !secondConnector.IsConnected
&& this.ConnectionType != secondConnector.ConnectionType;
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 890cf3fa6d7260842a21ef8f5fb2f85a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Integrations/Physic Cables/Scripts/Connector.cs
uploadId: 814740

View File

@@ -0,0 +1,7 @@
namespace HInteractions
{
public interface IObjectHolder
{
Interactable SelectedObject { get; }
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 68631ca83c20f134c8c58fe11017b845
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Integrations/Physic Cables/Scripts/IObjectHolder.cs
uploadId: 814740

View File

@@ -0,0 +1,27 @@
using UnityEngine;
namespace HInteractions
{
[DisallowMultipleComponent]
public class Interactable : MonoBehaviour
{
public bool ShowPointerOnInterract { get; private set; } = true;
public bool IsSelected { get; private set; }
protected virtual void Awake ()
{
Deselect ();
}
public virtual void Select ()
{
IsSelected = true;
}
public virtual void Deselect ()
{
IsSelected = false;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: f85334871a376e74dac58628d938cba0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Integrations/Physic Cables/Scripts/Interactable.cs
uploadId: 814740

View File

@@ -0,0 +1,59 @@
using System.Collections.Generic;
using UnityEngine;
namespace HInteractions
{
[RequireComponent (typeof (Rigidbody))]
public class Liftable : Interactable
{
[field: SerializeField] public bool IsLift { get; private set; } = false;
[field: SerializeField] public Vector3 LiftDirectionOffset { get; private set; } = Vector3.zero;
public Rigidbody Rigidbody { get; protected set; }
public IObjectHolder ObjectHolder { get; protected set; }
private readonly List<(GameObject obj, int defaultLayer)> _defaultLayers = new List<(GameObject obj, int defaultLayer)> ();
protected override void Awake ()
{
base.Awake ();
Rigidbody = GetComponent<Rigidbody> ();
}
public virtual void PickUp (IObjectHolder holder, int layer)
{
if (IsLift)
return;
ObjectHolder = holder;
// save layers
_defaultLayers.Clear ();
foreach (Collider col in gameObject.GetComponentsInChildren<Collider> ())
_defaultLayers.Add ((col.gameObject, col.gameObject.layer));
// set
Rigidbody.useGravity = false;
Rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
foreach ((GameObject obj, int defaultLayer) item in _defaultLayers)
item.obj.layer = layer;
IsLift = true;
}
public virtual void Drop ()
{
if (!IsLift)
return;
ObjectHolder = null;
Rigidbody.useGravity = true;
Rigidbody.interpolation = RigidbodyInterpolation.None;
foreach ((GameObject obj, int defaultLayer) item in _defaultLayers)
item.obj.layer = item.defaultLayer;
IsLift = false;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 9ef0207d4aaff9d4caff8b520d1bd121
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Integrations/Physic Cables/Scripts/Liftable.cs
uploadId: 814740

View File

@@ -0,0 +1,613 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace HPhysic
{
public class PhysicCable : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
[SerializeField] private int numberOfPoints = 3;
[SerializeField] private float space = 0.3f;
[SerializeField] private float size = 0.3f;
[Space]
[Header ("Physics Settings")]
[Space]
[SerializeField] private float springForce = 200;
public float dragValueOnCablePieces = 0;
public float damperOnCablePieces = 0.2f;
public float cablePointMass = 0.1f;
public float cableExtremesMass = 1;
[Space]
[Header ("Break Settings")]
[Space]
public bool cableBreakEnabled = true;
public bool cableCanBreakOnlyIfConnected = true;
public float minTimeToBreak = 1;
public bool canBeBrokenExternallyEnabled = true;
[Space]
[Header ("Disconnect Cable Elements")]
[Space]
public bool disconnectCableWhenLongEnoughEnabled = true;
[SerializeField] private float brakeLengthMultiplier = 2f;
[SerializeField] private float minBrakeTime = 1f;
[Space]
[Header ("Cable Elements")]
[Space]
public GameObject start;
public GameObject end;
public GameObject connector0;
public GameObject point0;
[Space]
[Header ("Debug")]
[Space]
public bool isConnected;
public bool cableBroken;
public float cableLength;
public bool startConnected;
public bool endConnected;
[Space]
public List<int> brokenPointsIndex = new List<int> ();
public List<Transform> points;
public List<Transform> connectors;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnBreak;
public UnityEvent eventOnBreakFromTension;
[Space]
public bool useEventToDisconnectBothPoints;
public UnityEvent eventToDisconnectBothPoints;
private const string cloneText = "Part";
private Connector startConnector;
private Connector endConnector;
private float brakeLength;
private float timeToBrake = 1f;
float timeToBreak = 1;
public Connector StartConnector => startConnector;
public Connector EndConnector => endConnector;
public IReadOnlyList<Transform> Points => points;
private void Start ()
{
startConnector = start.GetComponent<Connector> ();
endConnector = end.GetComponent<Connector> ();
brakeLength = space * numberOfPoints * brakeLengthMultiplier + 2f;
points = new List<Transform> ();
connectors = new List<Transform> ();
points.Add (start.transform);
points.Add (point0.transform);
connectors.Add (connector0.transform);
for (int i = 1; i < numberOfPoints; i++) {
Transform conn = GetConnector (i);
if (conn == null) {
Debug.LogWarning ("Dont found connector number " + i);
} else {
connectors.Add (conn);
}
Transform point = GetPoint (i);
if (conn == null) {
Debug.LogWarning ("Dont found point number " + i);
} else {
points.Add (point);
}
}
Transform endConn = GetConnector (numberOfPoints);
if (endConn == null) {
Debug.LogWarning ("Dont found connector number " + numberOfPoints);
} else {
connectors.Add (endConn);
}
points.Add (end.transform);
}
private void Update ()
{
cableLength = 0f;
isConnected = startConnected || endConnected;
//startConnector.IsConnected || endConnector.IsConnected;
int numOfParts = connectors.Count;
Transform lastPoint = points [0];
for (int i = 0; i < numOfParts; i++) {
bool canCheckPoinResult = true;
if (cableBroken) {
if (brokenPointsIndex.Contains (i + 1)) {
canCheckPoinResult = false;
}
}
Transform nextPoint = points [i + 1];
Transform connector = connectors [i].transform;
connector.position = CountConPos (lastPoint.position, nextPoint.position);
if (lastPoint.position == nextPoint.position || nextPoint.position == connector.position || !canCheckPoinResult) {
connector.localScale = Vector3.zero;
} else {
connector.rotation = Quaternion.LookRotation (nextPoint.position - connector.position);
connector.localScale = CountSizeOfCon (lastPoint.position, nextPoint.position);
}
if (isConnected || !cableCanBreakOnlyIfConnected) {
cableLength += (lastPoint.position - nextPoint.position).magnitude;
}
lastPoint = nextPoint;
}
if (cableBreakEnabled && !cableBroken) {
if (isConnected || !cableCanBreakOnlyIfConnected) {
if (cableLength > brakeLength) {
timeToBreak -= Time.deltaTime;
if (timeToBreak < 0f) {
timeToBreak = minTimeToBreak;
cableBroken = true;
eventOnBreakFromTension.Invoke ();
checkEventOnBreak ();
}
} else {
timeToBreak = minTimeToBreak;
}
}
}
if (disconnectCableWhenLongEnoughEnabled) {
if (isConnected) {
if (cableLength > brakeLength) {
timeToBrake -= Time.deltaTime;
if (timeToBrake < 0f) {
//startConnector.Disconnect ();
//endConnector.Disconnect ();
timeToBrake = minBrakeTime;
checkEventToDisconnectBothPoints ();
}
} else {
timeToBrake = minBrakeTime;
}
}
}
}
public void setStartConnectedState (bool state)
{
startConnected = state;
}
public void setEndConnectedState (bool state)
{
endConnected = state;
}
public void UpdatePointsFromEditor ()
{
UpdatePoints ();
updatValuesFromEditor ();
updateComponent ();
}
private void UpdatePoints ()
{
if (!start || !end || !point0 || !connector0) {
Debug.LogWarning ("Can't update because one of objects to set is null!");
return;
}
// delete old
int length = transform.childCount;
for (int i = 0; i < length; i++) {
if (transform.GetChild (i).name.StartsWith (cloneText)) {
GKC_Utils.checkUnpackPrefabToDestroyObject (gameObject, transform.GetChild (i).gameObject);
length--;
i--;
}
}
// set new
Vector3 lastPos = start.transform.position;
Rigidbody lastBody = start.GetComponent<Rigidbody> ();
for (int i = 0; i < numberOfPoints; i++) {
GameObject cConnector = i == 0 ? connector0 : CreateNewCon (i);
GameObject cPoint = i == 0 ? point0 : CreateNewPoint (i);
Vector3 newPos = CountNewPointPos (lastPos);
cPoint.transform.position = newPos;
cPoint.transform.localScale = Vector3.one * size;
cPoint.transform.rotation = transform.rotation;
SetSpring (cPoint.GetComponent<SpringJoint> (), lastBody);
lastBody = cPoint.GetComponent<Rigidbody> ();
cConnector.transform.position = CountConPos (lastPos, newPos);
cConnector.transform.localScale = CountSizeOfCon (lastPos, newPos);
cConnector.transform.rotation = CountRoationOfCon (lastPos, newPos);
lastPos = newPos;
}
Vector3 endPos = CountNewPointPos (lastPos);
end.transform.position = endPos;
SpringJoint lastBodySpringJoint = lastBody.gameObject.AddComponent<SpringJoint> ();
//if (lastBodySpringJoint == null) {
// lastBodySpringJoint = lastBody.gameObject.AddComponent<SpringJoint> ();
//}
SetSpring (lastBodySpringJoint, end.GetComponent<Rigidbody> ());
GameObject endConnector = CreateNewCon (numberOfPoints);
endConnector.transform.position = CountConPos (lastPos, endPos);
endConnector.transform.rotation = CountRoationOfCon (lastPos, endPos);
}
void updatValuesFromEditor ()
{
Component [] components = GetComponentsInChildren (typeof (Rigidbody));
foreach (Rigidbody child in components) {
child.linearDamping = dragValueOnCablePieces;
child.mass = cablePointMass;
}
Rigidbody startRigidbody = start.GetComponent<Rigidbody> ();
if (startRigidbody != null) {
startRigidbody.mass = cableExtremesMass;
}
Rigidbody endRigidbody = end.GetComponent<Rigidbody> ();
if (endRigidbody != null) {
endRigidbody.mass = cableExtremesMass;
}
components = GetComponentsInChildren (typeof (SpringJoint));
foreach (SpringJoint child in components) {
child.spring = springForce;
child.damper = damperOnCablePieces;
}
updateComponent ();
}
Vector3 CountNewPointPos (Vector3 lastPos)
{
return lastPos + transform.forward * space;
}
public void AddPointFromEditor ()
{
AddPoint ();
updateComponent ();
}
private void AddPoint ()
{
Transform lastprevPoint = GetPoint (numberOfPoints - 1);
if (lastprevPoint == null) {
Debug.LogWarning ("Dont found point number " + (numberOfPoints - 1));
return;
}
Rigidbody endRB = end.GetComponent<Rigidbody> ();
foreach (var spring in lastprevPoint.GetComponents<SpringJoint> ()) {
if (spring.connectedBody == endRB) {
DestroyImmediate (spring);
}
}
GameObject cPoint = CreateNewPoint (numberOfPoints);
GameObject cConnector = CreateNewCon (numberOfPoints + 1);
cPoint.transform.position = end.transform.position;
cPoint.transform.rotation = end.transform.rotation;
cPoint.transform.localScale = Vector3.one * size;
SetSpring (cPoint.GetComponent<SpringJoint> (), lastprevPoint.GetComponent<Rigidbody> ());
SpringJoint cPointSpringJoint = cPoint.gameObject.AddComponent<SpringJoint> ();
//if (cPointSpringJoint == null) {
// cPointSpringJoint = cPoint.gameObject.AddComponent<SpringJoint> ();
//}
SetSpring (cPointSpringJoint, endRB);
// fix end
end.transform.position += end.transform.forward * space;
cConnector.transform.position = CountConPos (cPoint.transform.position, end.transform.position);
cConnector.transform.localScale = CountSizeOfCon (cPoint.transform.position, end.transform.position);
cConnector.transform.rotation = CountRoationOfCon (cPoint.transform.position, end.transform.position);
numberOfPoints++;
}
public void RemovePointFromEditor ()
{
RemovePoint ();
updateComponent ();
}
private void RemovePoint ()
{
if (numberOfPoints < 2) {
Debug.LogWarning ("Cable can't be shorter then 1");
return;
}
Transform lastprevPoint = GetPoint (numberOfPoints - 1);
if (lastprevPoint == null) {
Debug.LogWarning ("Dont found point number " + (numberOfPoints - 1));
return;
}
Transform lastprevCon = GetConnector (numberOfPoints);
if (lastprevCon == null) {
Debug.LogWarning ("Dont found connector number " + (numberOfPoints));
return;
}
Transform lastlastprevPoint = GetPoint (numberOfPoints - 2);
if (lastlastprevPoint == null) {
Debug.LogWarning ("Dont found point number " + (numberOfPoints - 2));
return;
}
Rigidbody endRB = end.GetComponent<Rigidbody> ();
SpringJoint lastlastprevPointSpringJoint = lastlastprevPoint.gameObject.AddComponent<SpringJoint> ();
//if (lastlastprevPointSpringJoint == null) {
// lastlastprevPointSpringJoint = lastlastprevPoint.gameObject.AddComponent<SpringJoint> ();
//}
SetSpring (lastlastprevPointSpringJoint, endRB);
end.transform.position = lastprevPoint.position;
end.transform.rotation = lastprevPoint.rotation;
GKC_Utils.checkUnpackPrefabToDestroyObject (gameObject, lastprevPoint.gameObject);
GKC_Utils.checkUnpackPrefabToDestroyObject (gameObject, lastprevCon.gameObject);
numberOfPoints--;
}
private Vector3 CountConPos (Vector3 start, Vector3 end) => (start + end) / 2f;
private Vector3 CountSizeOfCon (Vector3 start, Vector3 end) => new Vector3 (size, size, (start - end).magnitude / 2f);
private Quaternion CountRoationOfCon (Vector3 start, Vector3 end) => Quaternion.LookRotation (end - start, Vector3.right);
private string ConnectorName (int index) => $"{cloneText}_{index}_Conn";
private string PointName (int index) => $"{cloneText}_{index}_Point";
private Transform GetConnector (int index) => index > 0 ? transform.Find (ConnectorName (index)) : connector0.transform;
private Transform GetPoint (int index) => index > 0 ? transform.Find (PointName (index)) : point0.transform;
public void SetSpring (SpringJoint spring, Rigidbody connectedBody)
{
spring.connectedBody = connectedBody;
spring.spring = springForce;
spring.damper = damperOnCablePieces;
spring.autoConfigureConnectedAnchor = false;
spring.anchor = Vector3.zero;
spring.connectedAnchor = Vector3.zero;
spring.minDistance = space;
spring.maxDistance = space;
}
private GameObject CreateNewPoint (int index)
{
GameObject temp = Instantiate (point0);
temp.name = PointName (index);
temp.transform.parent = transform;
return temp;
}
private GameObject CreateNewCon (int index)
{
GameObject temp = Instantiate (connector0);
temp.name = ConnectorName (index);
temp.transform.parent = transform;
return temp;
}
public void breakRandomPoint ()
{
bool randomPointFound = false;
int counter = 0;
int randomPointIndex = -1;
while (!randomPointFound) {
randomPointIndex = Random.Range (1, numberOfPoints - 1);
if (!cableBroken) {
randomPointFound = true;
}
if (!brokenPointsIndex.Contains (randomPointIndex)) {
randomPointFound = true;
}
counter++;
if (counter > 100) {
randomPointFound = true;
randomPointIndex = -1;
}
}
if (randomPointIndex > -1) {
SpringJoint currentSpringJoint = points [randomPointIndex].GetComponent<SpringJoint> ();
if (currentSpringJoint != null) {
Destroy (currentSpringJoint);
}
brokenPointsIndex.Add (randomPointIndex);
cableBroken = true;
checkEventOnBreak ();
}
}
public void breakPoint (Transform pointTransform)
{
if (canBeBrokenExternallyEnabled) {
int currentIndex = points.IndexOf (pointTransform);
if (currentIndex > -1) {
SpringJoint currentSpringJoint = points [currentIndex].GetComponent<SpringJoint> ();
if (currentSpringJoint != null) {
Destroy (currentSpringJoint);
}
brokenPointsIndex.Add (currentIndex);
cableBroken = true;
checkEventOnBreak ();
}
}
}
public void breakAllPoints ()
{
if (canBeBrokenExternallyEnabled) {
int pointsCount = points.Count;
for (int i = 0; i < pointsCount; i++) {
breakPoint (points [i]);
}
}
}
public void checkEventToDisconnectBothPoints ()
{
if (useEventToDisconnectBothPoints) {
eventToDisconnectBothPoints.Invoke ();
}
}
public void checkEventOnBreak ()
{
eventOnBreak.Invoke ();
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Info Physics Cable" + gameObject.name, gameObject);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8a73ca4efb287e142b4032b0fac4fb79
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Integrations/Physic Cables/Scripts/PhysicCable.cs
uploadId: 814740

View File

@@ -0,0 +1,42 @@
using System.Collections;
using UnityEngine;
using HInteractions;
namespace HPhysic
{
[RequireComponent (typeof (Connector))]
public class PhysicCableCon : Liftable
{
private Connector _connector;
protected override void Awake ()
{
base.Awake ();
_connector = gameObject.GetComponent<Connector> ();
}
public override void PickUp (IObjectHolder holder, int layer)
{
base.PickUp (holder, layer);
if (_connector.ConnectedTo)
_connector.Disconnect ();
}
public override void Drop ()
{
if (ObjectHolder.SelectedObject && ObjectHolder.SelectedObject.TryGetComponent (out Connector secondConnector)) {
if (_connector.CanConnect (secondConnector)) {
secondConnector.Connect (_connector);
} else if (!secondConnector.IsConnected) {
transform.rotation = secondConnector.ConnectionRotation * _connector.RotationOffset;
transform.position = (secondConnector.ConnectionPosition + secondConnector.ConnectedOutOffset * 0.2f) - (_connector.ConnectionPosition - _connector.transform.position);
}
}
base.Drop ();
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: c5481f564cd754547b202b32a524a988
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Integrations/Physic Cables/Scripts/PhysicCableCon.cs
uploadId: 814740

View File

@@ -0,0 +1,55 @@
using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
namespace HPhysic
{
[CustomEditor (typeof (PhysicCable))]
public class PhysicCableEditor : Editor
{
PhysicCable manager;
void OnEnable ()
{
manager = (PhysicCable)target;
}
public override void OnInspectorGUI ()
{
DrawDefaultInspector ();
EditorGUILayout.Space ();
GUILayout.Label ("EDITOR BUTTONS", EditorStyles.boldLabel);
EditorGUILayout.Space ();
if (GUILayout.Button ("Update Points & Values")) {
if (!Application.isPlaying) {
manager.UpdatePointsFromEditor ();
}
}
EditorGUILayout.Space ();
if (GUILayout.Button ("Add Point")) {
if (!Application.isPlaying) {
manager.AddPointFromEditor ();
}
}
EditorGUILayout.Space ();
if (GUILayout.Button ("Remove Point")) {
if (!Application.isPlaying) {
manager.RemovePointFromEditor ();
}
}
EditorGUILayout.Space ();
}
}
}
#endif

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: d683a7afdc244914daa9c5dbd4b9f9e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Integrations/Physic Cables/Scripts/PhysicCableEditor.cs
uploadId: 814740