named anchors

This commit is contained in:
klemek
2020-12-22 17:22:59 +01:00
parent d208236adc
commit 330b044c6b
19 changed files with 656 additions and 118 deletions
+4
View File
@@ -15,6 +15,10 @@ PrefabInstance:
propertyPath: m_Name
value: Anchor (Big)
objectReference: {fileID: 0}
- target: {fileID: 7299001212308582520, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
propertyPath: m_text
value:
objectReference: {fileID: 0}
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
propertyPath: m_RootOrder
value: 0
+240 -24
View File
@@ -9,9 +9,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 8599692958760628507}
- component: {fileID: 6867288177529611813}
- component: {fileID: -7307756874029176930}
- component: {fileID: 8643366489253547345}
- component: {fileID: -7307756874029176930}
m_Layer: 0
m_Name: Anchor
m_TagString: Untagged
@@ -29,18 +28,84 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.5, y: 0.5, z: -1}
m_LocalScale: {x: 0.5, y: 0.5, z: 1}
m_Children: []
m_Children:
- {fileID: 5862569722757527212}
- {fileID: 5766358859322875561}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &6867288177529611813
SpriteRenderer:
--- !u!58 &8643366489253547345
CircleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1824742176375353076}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
serializedVersion: 2
m_Radius: 0.75
--- !u!114 &-7307756874029176930
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1824742176375353076}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d38ff3984e75ad44398ee5927f8fbcf8, type: 3}
m_Name:
m_EditorClassIdentifier:
Name:
IsInput: 0
ScaleIncrease: 1.5
Orientation: {x: 0, y: 0}
TextSpace: 3.5
--- !u!1 &5848970826564749437
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5862569722757527212}
- component: {fileID: 1113731939458196735}
m_Layer: 0
m_Name: Sprite
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5862569722757527212
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5848970826564749437}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 8599692958760628507}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1113731939458196735
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5848970826564749437}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
@@ -72,7 +137,7 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 2
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 0415f46fc23af284da343f01713b8c27, type: 3}
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_FlipX: 0
@@ -84,35 +149,186 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &-7307756874029176930
--- !u!1 &7856049522120244897
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5766358859322875561}
- component: {fileID: 2224638522192173631}
- component: {fileID: 7299001212308582520}
- component: {fileID: 9072568361145610695}
m_Layer: 0
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &5766358859322875561
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7856049522120244897}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 8599692958760628507}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 5, y: 5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &2224638522192173631
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7856049522120244897}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: b26bb2dabfa295a469f3aaeaf0608c66, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!114 &7299001212308582520
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1824742176375353076}
m_GameObject: {fileID: 7856049522120244897}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d38ff3984e75ad44398ee5927f8fbcf8, type: 3}
m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3}
m_Name:
m_EditorClassIdentifier:
Name:
IsInput: 0
ScaleIncrease: 1.5
Orientation: {x: 0, y: 0}
--- !u!58 &8643366489253547345
CircleCollider2D:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2100000, guid: b26bb2dabfa295a469f3aaeaf0608c66, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4278190080
m_fontColor: {r: 0, g: 0, b: 0, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 20
m_fontSizeBase: 20
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 0
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 1
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_renderer: {fileID: 2224638522192173631}
m_maskType: 0
_SortingLayerID: 0
_SortingOrder: 0
--- !u!114 &9072568361145610695
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1824742176375353076}
m_GameObject: {fileID: 7856049522120244897}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
serializedVersion: 2
m_Radius: 0.75
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 644a8320ad8f9c54db2cf3119c482ab8, type: 3}
m_Name:
m_EditorClassIdentifier:
SubTextOffset: {x: -0.8, y: 0.2, z: 0}
+2 -2
View File
@@ -198,8 +198,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5358625439717083291}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 3, y: -2.5, z: 1}
m_LocalScale: {x: 5.5, y: 4.5, z: 1}
m_LocalPosition: {x: 1.5, y: -1.5, z: 1}
m_LocalScale: {x: 2.5, y: 2.5, z: 1}
m_Children: []
m_Father: {fileID: 2070848596161447923}
m_RootOrder: 1
+1 -1
View File
@@ -143,7 +143,7 @@ MonoBehaviour:
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2100000, guid: 0413ae694cef75c49bdcae40228a6dd0, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
+2 -8
View File
@@ -81,10 +81,7 @@ namespace CompuLogic
_currentGate = gate;
_currentGateDelta = MousePos - _currentGate.transform.position;
_currentGateInitialPos = created ? (Vector3?)null : _currentGate.transform.position;
foreach (var renderer in _currentGate.GetComponentsInChildren<SpriteRenderer>())
{
renderer.sortingLayerName = "moving";
}
_currentGate.SetSortingLayerRecursive("moving");
}
public void RequestDelete()
@@ -203,10 +200,7 @@ namespace CompuLogic
}
else
{
foreach (var renderer in _currentGate.GetComponentsInChildren<SpriteRenderer>())
{
renderer.sortingLayerName = "default";
}
_currentGate.SetSortingLayerRecursive("default");
_currentGate.transform.position = _currentGate.transform.position.Round();
var currentBox = _currentGate.Box;
if (FindObjectsOfType<Gate>()
+2 -2
View File
@@ -18,7 +18,7 @@ namespace CompuLogic.UI
get
{
if(_maxSize == null)
_maxSize = GameManager.Instance.GateSprites.Select(s => Math.Max(s.rect.width, s.rect.height)).Max();
_maxSize = GameManager.Instance.GateSprites.Select(s => Mathf.Max(s.rect.width, s.rect.height)).Max();
return _maxSize.Value;
}
}
@@ -38,7 +38,7 @@ namespace CompuLogic.UI
{
var sprite = value.GetComponentInChildren<SpriteRenderer>().sprite;
Image.sprite = sprite;
Image.GetComponent<RectTransform>().sizeDelta = new Vector2(100f, 100 * Math.Max(sprite.rect.width, sprite.rect.height) / MaxSize);
Image.GetComponent<RectTransform>().sizeDelta = new Vector2(100f, 100 * Mathf.Max(sprite.rect.width, sprite.rect.height) / MaxSize);
gameObject.name = "UI_" + value.GateType.ToString();
Text.text = value.UIName;
}
+27
View File
@@ -58,5 +58,32 @@ namespace CompuLogic
{
return new Vector3(Mathf.Round(v.x), Mathf.Round(v.y), Mathf.Round(v.z));
}
public static void SetSortingLayerRecursive(this UnityEngine.Component obj, string sortingLayer)
{
if(obj.TryGetComponent<SpriteRenderer>(out var renderer))
{
renderer.SetSortingLayerRecursive(sortingLayer);
}
else
{
foreach (var subrenderer in obj.GetComponentsInChildren<SpriteRenderer>())
{
subrenderer.SetSortingLayerRecursive(sortingLayer);
}
}
}
public static void SetSortingLayerRecursive(this SpriteRenderer renderer, string sortingLayer)
{
foreach (var subrenderer in renderer.GetComponentsInChildren<SpriteRenderer>())
{
if(subrenderer != renderer)
{
subrenderer.SetSortingLayerRecursive(sortingLayer);
}
}
}
}
}
+52 -15
View File
@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
namespace CompuLogic.Workspace
@@ -13,6 +14,8 @@ namespace CompuLogic.Workspace
public bool IsInput;
public float ScaleIncrease;
public Vector2 Orientation;
public float TextSpace;
#endregion
@@ -24,25 +27,60 @@ namespace CompuLogic.Workspace
{
get
{
if (IsInput)
return Cables.Count > 0 && Cables.First().Activated;
else
return _activated;
if (IsInput)
return Cables.Count > 0 && Cables.First().Activated;
else
return _activated;
}
set
{
if (!IsInput)
_activated = value;
if (!IsInput)
_activated = value;
}
}
public bool Hovering { get; internal set; }
public bool ShowName
{
set
{
Text.gameObject.SetActive(value);
if (value)
{
Text.text = Name;
var rect = Text.GetComponent<RectTransform>();
rect.localRotation = (Mathf.Abs(Orientation.y) > Mathf.Epsilon) ? Quaternion.AngleAxis(90f, Vector3.forward) : Quaternion.identity;
rect.localPosition = new Vector3(Orientation.x, Orientation.y, 0f) * TextSpace;
Text.alignment = (Orientation.x < -Mathf.Epsilon || Orientation.y < -Mathf.Epsilon) ? TextAlignmentOptions.MidlineRight : TextAlignmentOptions.MidlineLeft;
}
}
}
public TextMeshPro Text
{
get
{
if (_text == null)
_text = GetComponentInChildren<TextMeshPro>(true);
return _text;
}
}
public SpriteRenderer Sprite
{
get
{
if (_sprite == null)
_sprite = GetComponentInChildren<SpriteRenderer>();
return _sprite;
}
}
#endregion
#region Private Properties
private Vector3 _scale;
private SpriteRenderer _sprite;
private TextMeshPro _text;
private Vector3 _scale;
private bool _activated;
private bool? _lastActivated;
@@ -55,8 +93,7 @@ namespace CompuLogic.Workspace
{
Gate = GetComponentInParent<Gate>();
Utils.RandomName($"{Gate.GateType}_{Name}", gameObject);
_scale = transform.localScale;
_sprite = GetComponent<SpriteRenderer>();
_scale = Sprite.transform.localScale;
Cables = new List<Cable>();
Orientation = Orientation.normalized;
}
@@ -69,16 +106,16 @@ namespace CompuLogic.Workspace
private void OnMouseEnter()
{
transform.localScale = _scale * ScaleIncrease;
Sprite.transform.localScale = _scale * ScaleIncrease;
GameManager.Instance.CurrentAnchor = this;
Hovering = true;
}
private void OnMouseExit()
{
transform.localScale = _scale;
Sprite.transform.localScale = _scale;
if (Equals(GameManager.Instance.CurrentAnchor))
GameManager.Instance.CurrentAnchor = null;
GameManager.Instance.CurrentAnchor = null;
Hovering = false;
}
@@ -88,7 +125,7 @@ namespace CompuLogic.Workspace
{
foreach(var cable in Cables)
{
Destroy(cable.gameObject);
Destroy(cable.gameObject);
}
}
@@ -114,8 +151,8 @@ namespace CompuLogic.Workspace
{
if (_lastActivated == null || _lastActivated != Activated)
{
_sprite.color = Activated ? GameManager.Instance.ActivatedColor : GameManager.Instance.DeadColor;
_lastActivated = Activated;
Sprite.color = Activated ? GameManager.Instance.ActivatedColor : GameManager.Instance.DeadColor;
_lastActivated = Activated;
}
}
@@ -67,11 +67,14 @@ namespace CompuLogic.Workspace
gate.UIName = string.IsNullOrEmpty(item.Name) ? gate.GateType.ToString() : item.Name;
var showAnchorNames = false;
if (string.IsNullOrEmpty(item.Skin))
{
gate.Sprite.Renderer.sprite = _defaultSprite;
gate.Sprite.Renderer.drawMode = SpriteDrawMode.Sliced;
gate.Sprite.Renderer.size = new Vector2(item.Width, item.Height);
showAnchorNames = true;
}
else
{
@@ -87,6 +90,7 @@ namespace CompuLogic.Workspace
var anchor = Instantiate(inputAnchor.Big ? _bigAnchorPrefab : _anchorPrefab);
anchor.transform.parent = prefab.transform;
inputAnchor.ConfigAnchor(anchor);
anchor.ShowName = showAnchorNames;
anchor.IsInput = true;
}
}
@@ -98,6 +102,7 @@ namespace CompuLogic.Workspace
var anchor = Instantiate(outputAnchor.Big ? _bigAnchorPrefab : _anchorPrefab);
anchor.transform.parent = prefab.transform;
outputAnchor.ConfigAnchor(anchor);
anchor.ShowName = showAnchorNames;
}
}
@@ -95,7 +95,6 @@ namespace CompuLogic.Workspace.Gates
internal class SRLatchGate : StatefulGateDefinition
{
public new string Name => "SR Latch";
public override string[] Inputs { get; } = new string[] { "S", "R" };
public override string[] Outputs { get; } = new string[] { "Q", "Q̅" };
@@ -115,7 +114,6 @@ namespace CompuLogic.Workspace.Gates
internal class JKLatchGate : StatefulGateDefinition
{
public new string Name => "JK Latch";
public override string[] Inputs { get; } = new string[] { "J", "K" };
public override string[] Outputs { get; } = new string[] { "Q", "Q̅" };
@@ -137,7 +135,6 @@ namespace CompuLogic.Workspace.Gates
internal class DLatchGate : StatefulGateDefinition
{
public new string Name => "D Latch";
public override string[] Inputs { get; } = new string[] { "D", "E" };
public override string[] Outputs { get; } = new string[] { "Q", "Q̅" };
@@ -159,7 +156,6 @@ namespace CompuLogic.Workspace.Gates
internal class SRFlipFlopGate : StatefulGateDefinition
{
public new string Name => "SR Flip-Flop";
public override string[] Inputs { get; } = new string[] { "CLK", "S", "R" };
public override string[] Outputs { get; } = new string[] { "Q", "Q̅" };
@@ -183,7 +179,6 @@ namespace CompuLogic.Workspace.Gates
internal class JKFlipFlopGate : StatefulGateDefinition
{
public new string Name => "JK Flip-Flop";
public override string[] Inputs { get; } = new string[] { "CLK", "J", "K" };
public override string[] Outputs { get; } = new string[] { "Q", "Q̅" };
@@ -209,7 +204,6 @@ namespace CompuLogic.Workspace.Gates
internal class DFlipFlopGate : StatefulGateDefinition
{
public new string Name => "D Flip-Flop";
public override string[] Inputs { get; } = new string[] { "CLK", "D" };
public override string[] Outputs { get; } = new string[] { "Q", "Q̅" };
@@ -229,7 +223,6 @@ namespace CompuLogic.Workspace.Gates
internal class TFlipFlopGate : StatefulGateDefinition
{
public new string Name => "T Flip-Flop";
public override string[] Inputs { get; } = new string[] { "CLK", "T" };
public override string[] Outputs { get; } = new string[] { "Q", "Q̅" };
@@ -254,7 +247,6 @@ namespace CompuLogic.Workspace.Gates
internal class HalfAddGate : StatelessGateDefinition
{
public new string Name => "Half Add.";
public override string[] Inputs { get; } = new string[] { "A", "B" };
public override string[] Outputs { get; } = new string[] { "S", "C" };
@@ -272,7 +264,6 @@ namespace CompuLogic.Workspace.Gates
internal class FullAddGate : StatelessGateDefinition
{
public new string Name => "Full Add.";
public override string[] Inputs { get; } = new string[] { "A", "B", "Cɪ" };
public override string[] Outputs { get; } = new string[] { "S", "C" };
@@ -291,7 +282,6 @@ namespace CompuLogic.Workspace.Gates
internal class HalfSubGate : StatelessGateDefinition
{
public new string Name => "Half Sub.";
public override string[] Inputs { get; } = new string[] { "A", "B" };
public override string[] Outputs { get; } = new string[] { "S", "C" };
@@ -310,7 +300,6 @@ namespace CompuLogic.Workspace.Gates
internal class FullSubGate : StatelessGateDefinition
{
public new string Name => "Full Add.";
public override string[] Inputs { get; } = new string[] { "A", "B", "Cɪ" };
public override string[] Outputs { get; } = new string[] { "S", "C" };
@@ -370,7 +359,6 @@ namespace CompuLogic.Workspace.Gates
internal class Mux2bGate : StatelessGateDefinition
{
public new string Name => "2bits Mux";
public override string[] Inputs { get; } = new string[] { "E", "S₀", "S₁", "D₀", "D₁", "D₂", "D₃" };
public override string[] Outputs { get; } = new string[] { "Y" };
@@ -397,7 +385,6 @@ namespace CompuLogic.Workspace.Gates
internal class Demux2bGate : StatelessGateDefinition
{
public new string Name => "2bits Demux";
public override string[] Inputs { get; } = new string[] { "E", "S₀", "S₁", "D" };
public override string[] Outputs { get; } = new string[] { "Y₀", "Y₁", "Y₂", "Y₃" };
@@ -419,7 +406,6 @@ namespace CompuLogic.Workspace.Gates
internal class Enc2b4bGate : StatelessGateDefinition
{
public new string Name => "2b/4b Enc.";
public override string[] Inputs { get; } = new string[] { "D₀", "D₁" };
public override string[] Outputs { get; } = new string[] { "Y₀", "Y₁", "Y₂", "Y₃" };
@@ -439,7 +425,6 @@ namespace CompuLogic.Workspace.Gates
internal class Dec4b2bGate : StatelessGateDefinition
{
public new string Name => "4b/2b Dec.";
public override string[] Inputs { get; } = new string[] { "D₀", "D₁", "D₂", "D₃"};
public override string[] Outputs { get; } = new string[] { "Y₀", "Y₁" };
@@ -463,7 +448,6 @@ namespace CompuLogic.Workspace.Gates
internal class SISO4bGate : StatefulGateDefinition
{
public new string Name => "4bits SISO";
public override string[] Inputs { get; } = new string[] { "CLK", "D" };
public override string[] Outputs { get; } = new string[] { "Q" };
@@ -491,7 +475,6 @@ namespace CompuLogic.Workspace.Gates
internal class SIPO4bGate : StatefulGateDefinition
{
public new string Name => "4bits SIPO";
public override string[] Inputs { get; } = new string[] { "CLK", "D" };
public override string[] Outputs { get; } = new string[] { "Q₀", "Q₁", "Q₂", "Q₃" };
@@ -519,7 +502,6 @@ namespace CompuLogic.Workspace.Gates
internal class PIPO4bGate : StatefulGateDefinition
{
public new string Name => "4bits PIPO";
public override string[] Inputs { get; } = new string[] { "CLK", "D₀", "D₁", "D₂", "D₃" };
public override string[] Outputs { get; } = new string[] { "Q₀", "Q₁", "Q₂", "Q₃" };
@@ -554,7 +536,6 @@ namespace CompuLogic.Workspace.Gates
internal class Counter2bGate : StatefulGateDefinition
{
public new string Name => "2bits Count.";
public override string[] Inputs { get; } = new string[] { "CLK", "RST" };
public override string[] Outputs { get; } = new string[] { "Q₀", "Q₁" };
@@ -586,7 +567,6 @@ namespace CompuLogic.Workspace.Gates
internal class Counter4bGate : StatefulGateDefinition
{
public new string Name => "4bits Count.";
public override string[] Inputs { get; } = new string[] { "CLK", "RST" };
public override string[] Outputs { get; } = new string[] { "Q₀", "Q₁", "Q₂", "Q₃" };
+45
View File
@@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
namespace CompuLogic
{
public class OverlineCorrector : MonoBehaviour
{
public Vector3 SubTextOffset;
#region Unity Properties
#endregion
#region Public Properties
#endregion
#region Private Properties
#endregion
#region Unity Methods
private void FixedUpdate()
{
var subText = GetComponentInChildren<TMP_SubMesh>();
if(subText != null && Mathf.Abs(subText.transform.localPosition.magnitude) < Mathf.Epsilon)
subText.transform.localPosition = SubTextOffset;
}
#endregion
#region Public Methods
#endregion
#region Private Methods
#endregion
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 644a8320ad8f9c54db2cf3119c482ab8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because one or more lines are too long
@@ -0,0 +1,63 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: LiberationSans SDF UI
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
m_ShaderKeywords: OUTLINE_ON
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 28684132378477856, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _ColorMask: 15
- _CullMode: 0
- _FaceDilate: 0.5
- _GradientScale: 10
- _MaskSoftnessX: 0
- _MaskSoftnessY: 0
- _OutlineSoftness: 0
- _OutlineWidth: 0.5
- _PerspectiveFilter: 0.875
- _ScaleRatioA: 0.75789475
- _ScaleRatioB: 1
- _ScaleRatioC: 0.28125
- _ScaleX: 1
- _ScaleY: 1
- _ShaderFlags: 0
- _Sharpness: 0
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _TextureHeight: 1024
- _TextureWidth: 1024
- _UnderlayDilate: 0
- _UnderlayOffsetX: 0
- _UnderlayOffsetY: 0
- _UnderlaySoftness: 0
- _VertexOffsetX: 0
- _VertexOffsetY: 0
- _WeightBold: 0.75
- _WeightNormal: 0
m_Colors:
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
m_BuildTextureStacks: []
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0413ae694cef75c49bdcae40228a6dd0
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,63 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: LiberationSans SDF Workspace
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 28684132378477856, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _ColorMask: 15
- _CullMode: 0
- _FaceDilate: 0.5
- _GradientScale: 10
- _MaskSoftnessX: 0
- _MaskSoftnessY: 0
- _OutlineSoftness: 0
- _OutlineWidth: 0.5
- _PerspectiveFilter: 0.875
- _ScaleRatioA: 0.75789475
- _ScaleRatioB: 1
- _ScaleRatioC: 0.28125
- _ScaleX: 1
- _ScaleY: 1
- _ShaderFlags: 0
- _Sharpness: 0
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _TextureHeight: 1024
- _TextureWidth: 1024
- _UnderlayDilate: 0
- _UnderlayOffsetX: 0
- _UnderlayOffsetY: 0
- _UnderlaySoftness: 0
- _VertexOffsetX: 0
- _VertexOffsetY: 0
- _WeightBold: 0.75
- _WeightNormal: 0
m_Colors:
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
m_BuildTextureStacks: []
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b26bb2dabfa295a469f3aaeaf0608c66
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
+54 -12
View File
@@ -95,30 +95,72 @@ list:
300:
name: SR Latch
width: 5
height: 6
height: 5
input:
- S 0.5 1.5 W
- R 0.5 4.5 W
- R 0.5 3.5 W
output:
- Q 4.5 1.5 W
- Q̅ 4.5 4.5 W
- Q 4.5 1.5 E
- Q̅ 4.5 3.5 E
310:
name: JK Latch
width: 5
height: 6
height: 5
input:
- J 0.5 1.5 W
- K 0.5 4.5 W
- K 0.5 3.5 W
output:
- Q 4.5 1.5 W
- Q̅ 4.5 4.5 W
- Q 4.5 1.5 E
- Q̅ 4.5 3.5 E
320:
name: D Latch
width: 5
height: 6
height: 5
input:
- D 0.5 1.5 W
- E 0.5 4.5 W
- E 0.5 3.5 W
output:
- Q 4.5 1.5 W
- Q̅ 4.5 4.5 W
- Q 4.5 1.5 E
- Q̅ 4.5 3.5 E
400:
name: SR Flip-Flop
width: 5
height: 7
input:
- S 0.5 1.5 W
- R 0.5 3.5 W
- CLK 0.5 5.5 W
output:
- Q 4.5 1.5 E
- Q̅ 4.5 5.5 E
410:
name: JK Flip-Flop
width: 5
height: 7
input:
- J 0.5 1.5 W
- K 0.5 3.5 W
- CLK 0.5 5.5 W
output:
- Q 4.5 1.5 E
- Q̅ 4.5 5.5 E
420:
name: D Flip-Flop
width: 5
height: 7
input:
- D 0.5 1.5 W
- CLK 0.5 5.5 W
output:
- Q 4.5 1.5 E
- Q̅ 4.5 5.5 E
430:
name: T Flip-Flop
width: 5
height: 7
input:
- T 0.5 1.5 W
- CLK 0.5 5.5 W
output:
- Q 4.5 1.5 E
- Q̅ 4.5 5.5 E
-1
View File
@@ -2,7 +2,6 @@ TODO
-(1) finish gate book
-(1) mux/demux svg
-(1) change fonts
-(2) named anchors (dezoom hide ?)
-(3) clocks (1Hz, 5Hz, 10Hz, etc.)
-(3) cable overlap (same/diff circuit)
-(5) cable management