mirror of
https://github.com/BotChain-Robots/ui.git
synced 2026-07-08 15:07:22 +02:00
UI material + environment change
Made-with: Cursor
This commit is contained in:
@@ -5,47 +5,40 @@ using UnityEngine.UI;
|
||||
public class ControlPanel : MonoBehaviour
|
||||
{
|
||||
[Header("Core UI (assign in Inspector)")]
|
||||
public TMP_InputField inputField;
|
||||
public TMP_Dropdown directionDropdown;
|
||||
public Button button; // existing Send/Rotate button in hierarchy
|
||||
public TMP_InputField inputField; // was DegreesInputField
|
||||
public TMP_Dropdown directionDropdown; // was DirectionDropdown
|
||||
public Button button; // was RotateButton
|
||||
|
||||
private enum Mode { None, DC, Display, Speaker }
|
||||
private enum Mode { None, DC, Display, Gripper }
|
||||
private Mode _mode = Mode.None;
|
||||
|
||||
private DCMotorModule _dc;
|
||||
private DisplayModule _display;
|
||||
private SpeakerModule _speaker;
|
||||
private GripperModule _gripper;
|
||||
|
||||
// Keep separate inputs so they don't interfere
|
||||
private string _savedDCInput = "";
|
||||
private int _savedDirectionIndex = 0;
|
||||
private string _savedDisplayInput = "";
|
||||
private string _savedGripperInput = "";
|
||||
|
||||
// Found automatically (no hierarchy edits)
|
||||
private TextMeshProUGUI _caption; // child "DegreesCaption"
|
||||
private TextMeshProUGUI _buttonText; // child "RotateButton/Text (TMP)"
|
||||
private GameObject _directionCaptionGO;
|
||||
private GameObject _directionDropdownGO;
|
||||
|
||||
// Created in code (Speaker mode only)
|
||||
private Button _uploadButton;
|
||||
private TextMeshProUGUI _uploadButtonText;
|
||||
private Button _playButton;
|
||||
private TextMeshProUGUI _playButtonText;
|
||||
// Found automatically (no new UI objects)
|
||||
private TextMeshProUGUI _caption; // DegreesCaption text
|
||||
private TextMeshProUGUI _buttonText; // RotateButton/Text (TMP)
|
||||
private GameObject _directionCaptionGO; // DirectionCaption
|
||||
private GameObject _directionDropdownGO; // DirectionDropdown GameObject
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
CacheUIFromHierarchy();
|
||||
|
||||
// Create these once; hide unless Speaker mode
|
||||
CreateUploadButtonIfNeeded();
|
||||
CreatePlayButtonIfNeeded();
|
||||
|
||||
if (button != null)
|
||||
{
|
||||
button.onClick.RemoveAllListeners();
|
||||
button.onClick.AddListener(OnMainButtonClicked);
|
||||
button.onClick.AddListener(OnButtonClicked);
|
||||
}
|
||||
|
||||
// Cache typed values so switching modules restores what you typed
|
||||
if (inputField != null)
|
||||
{
|
||||
inputField.onValueChanged.AddListener(_ => CacheCurrentInput());
|
||||
@@ -61,17 +54,37 @@ public class ControlPanel : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this whenever a DC or Display module is selected.
|
||||
/// </summary>
|
||||
public void Initialize(ModuleBase module)
|
||||
{
|
||||
CacheCurrentInput();
|
||||
|
||||
_dc = module as DCMotorModule;
|
||||
_display = module as DisplayModule;
|
||||
_speaker = module as SpeakerModule;
|
||||
_gripper = module as GripperModule;
|
||||
|
||||
if (_dc != null) { SwitchMode(Mode.DC); gameObject.SetActive(true); return; }
|
||||
if (_display != null) { SwitchMode(Mode.Display); gameObject.SetActive(true); return; }
|
||||
if (_speaker != null) { SwitchMode(Mode.Speaker); gameObject.SetActive(true); return; }
|
||||
if (_dc != null)
|
||||
{
|
||||
SwitchMode(Mode.DC);
|
||||
gameObject.SetActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_display != null)
|
||||
{
|
||||
SwitchMode(Mode.Display);
|
||||
gameObject.SetActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_gripper != null)
|
||||
{
|
||||
SwitchMode(Mode.Gripper);
|
||||
gameObject.SetActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
HidePanel();
|
||||
}
|
||||
@@ -83,13 +96,12 @@ public class ControlPanel : MonoBehaviour
|
||||
_mode = Mode.None;
|
||||
_dc = null;
|
||||
_display = null;
|
||||
_speaker = null;
|
||||
SetUploadVisible(false);
|
||||
SetPlayVisible(false);
|
||||
_gripper = null;
|
||||
}
|
||||
|
||||
private void CacheUIFromHierarchy()
|
||||
{
|
||||
// Assumes this script is on the parent that contains these children
|
||||
var captionT = transform.Find("DegreesCaption");
|
||||
if (captionT != null) _caption = captionT.GetComponent<TextMeshProUGUI>();
|
||||
|
||||
@@ -110,78 +122,47 @@ public class ControlPanel : MonoBehaviour
|
||||
|
||||
if (_mode == Mode.DC)
|
||||
{
|
||||
SetCaption("Degrees");
|
||||
SetCaptionVisible(true);
|
||||
SetMainButtonText("Rotate");
|
||||
if (_caption != null) _caption.text = "Degrees";
|
||||
if (_buttonText != null) _buttonText.text = "Rotate";
|
||||
SetDirectionVisible(true);
|
||||
SetInputVisible(true);
|
||||
SetUploadVisible(false);
|
||||
SetPlayVisible(false);
|
||||
|
||||
if (inputField != null)
|
||||
{
|
||||
inputField.readOnly = false;
|
||||
inputField.SetTextWithoutNotify(_savedDCInput);
|
||||
}
|
||||
|
||||
if (directionDropdown != null)
|
||||
directionDropdown.SetValueWithoutNotify(_savedDirectionIndex);
|
||||
}
|
||||
else if (_mode == Mode.Display)
|
||||
{
|
||||
SetCaption("Text");
|
||||
SetCaptionVisible(true);
|
||||
SetMainButtonText("Send");
|
||||
if (_caption != null) _caption.text = "Text";
|
||||
if (_buttonText != null) _buttonText.text = "Send";
|
||||
SetDirectionVisible(false);
|
||||
SetInputVisible(true);
|
||||
SetUploadVisible(false);
|
||||
SetPlayVisible(false);
|
||||
|
||||
if (inputField != null)
|
||||
{
|
||||
inputField.readOnly = false;
|
||||
// Prefer module's current displayText; fallback to last typed text
|
||||
string toShow = _savedDisplayInput;
|
||||
if (_display != null && !string.IsNullOrEmpty(_display.displayText))
|
||||
toShow = _display.displayText;
|
||||
|
||||
if (inputField != null)
|
||||
inputField.SetTextWithoutNotify(toShow);
|
||||
}
|
||||
}
|
||||
else if (_mode == Mode.Speaker)
|
||||
else if (_mode == Mode.Gripper)
|
||||
{
|
||||
// Speaker UI: no input field (removes the white box behind buttons)
|
||||
SetMainButtonText("Send Audio");
|
||||
SetCaptionVisible(false);
|
||||
if (_caption != null) _caption.text = "Degrees";
|
||||
if (_buttonText != null) _buttonText.text = "Apply";
|
||||
SetDirectionVisible(false);
|
||||
SetInputVisible(false);
|
||||
|
||||
// Show speaker buttons
|
||||
SetUploadVisible(true);
|
||||
SetPlayVisible(true);
|
||||
if (inputField != null)
|
||||
inputField.SetTextWithoutNotify(_gripper != null ? _gripper.currentAngle.ToString("F0") : _savedGripperInput);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCaption(string text)
|
||||
{
|
||||
if (_caption != null) _caption.text = text;
|
||||
}
|
||||
|
||||
private void SetMainButtonText(string text)
|
||||
{
|
||||
if (_buttonText != null) _buttonText.text = text;
|
||||
}
|
||||
|
||||
private void SetDirectionVisible(bool visible)
|
||||
{
|
||||
if (_directionCaptionGO != null) _directionCaptionGO.SetActive(visible);
|
||||
if (_directionDropdownGO != null) _directionDropdownGO.SetActive(visible);
|
||||
}
|
||||
|
||||
private void SetInputVisible(bool visible)
|
||||
{
|
||||
if (inputField != null && inputField.gameObject.activeSelf != visible)
|
||||
inputField.gameObject.SetActive(visible);
|
||||
}
|
||||
|
||||
private void CacheCurrentInput()
|
||||
{
|
||||
if (inputField == null) return;
|
||||
@@ -189,19 +170,28 @@ public class ControlPanel : MonoBehaviour
|
||||
if (_mode == Mode.DC)
|
||||
{
|
||||
_savedDCInput = inputField.text;
|
||||
if (directionDropdown != null) _savedDirectionIndex = directionDropdown.value;
|
||||
if (directionDropdown != null)
|
||||
_savedDirectionIndex = directionDropdown.value;
|
||||
}
|
||||
else if (_mode == Mode.Display)
|
||||
{
|
||||
_savedDisplayInput = inputField.text;
|
||||
}
|
||||
else if (_mode == Mode.Gripper)
|
||||
{
|
||||
_savedGripperInput = inputField.text;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMainButtonClicked()
|
||||
private void OnButtonClicked()
|
||||
{
|
||||
if (_mode == Mode.DC)
|
||||
{
|
||||
if (_dc == null) return;
|
||||
if (_dc == null)
|
||||
{
|
||||
Debug.LogWarning("ControlPanel: No DC module selected.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!float.TryParse(inputField.text, out float degrees))
|
||||
{
|
||||
@@ -214,206 +204,30 @@ public class ControlPanel : MonoBehaviour
|
||||
}
|
||||
else if (_mode == Mode.Display)
|
||||
{
|
||||
if (_display == null) return;
|
||||
_display.SetDisplayText(inputField != null ? inputField.text : "");
|
||||
}
|
||||
else if (_mode == Mode.Speaker)
|
||||
if (_display == null)
|
||||
{
|
||||
if (_speaker == null) return;
|
||||
_speaker.SendAudioToHardware(); // Send Audio = upload to hardware (your implementation)
|
||||
}
|
||||
Debug.LogWarning("ControlPanel: No Display module selected.");
|
||||
return;
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// Styling helpers (copy Send button look)
|
||||
// -------------------------
|
||||
|
||||
private void CopyButtonStyle(Button source, Button target)
|
||||
{
|
||||
if (source == null || target == null) return;
|
||||
|
||||
// Button settings
|
||||
target.transition = source.transition;
|
||||
target.colors = source.colors;
|
||||
target.spriteState = source.spriteState;
|
||||
target.navigation = source.navigation;
|
||||
target.interactable = source.interactable;
|
||||
|
||||
// Image settings
|
||||
var srcImg = source.GetComponent<Image>();
|
||||
var dstImg = target.GetComponent<Image>();
|
||||
if (srcImg != null && dstImg != null)
|
||||
{
|
||||
dstImg.sprite = srcImg.sprite;
|
||||
dstImg.type = srcImg.type;
|
||||
dstImg.pixelsPerUnitMultiplier = srcImg.pixelsPerUnitMultiplier;
|
||||
dstImg.material = srcImg.material;
|
||||
dstImg.color = srcImg.color;
|
||||
dstImg.raycastTarget = srcImg.raycastTarget;
|
||||
string text = inputField != null ? inputField.text : "";
|
||||
_display.SetDisplayText(text); // <- THIS is where Display module gets the text
|
||||
}
|
||||
else if (_mode == Mode.Gripper)
|
||||
{
|
||||
if (_gripper == null)
|
||||
{
|
||||
Debug.LogWarning("ControlPanel: No Gripper module selected.");
|
||||
return;
|
||||
}
|
||||
|
||||
private void CopyTMPStyle(TextMeshProUGUI source, TextMeshProUGUI target)
|
||||
if (!float.TryParse(inputField.text, out float degrees))
|
||||
{
|
||||
if (source == null || target == null) return;
|
||||
|
||||
target.font = source.font;
|
||||
target.fontSharedMaterial = source.fontSharedMaterial;
|
||||
target.fontStyle = source.fontStyle;
|
||||
target.fontSize = source.fontSize;
|
||||
target.enableAutoSizing = source.enableAutoSizing;
|
||||
target.color = source.color;
|
||||
target.enableVertexGradient = source.enableVertexGradient;
|
||||
target.alignment = source.alignment;
|
||||
target.enableWordWrapping = source.enableWordWrapping;
|
||||
target.richText = source.richText;
|
||||
Debug.LogWarning("ControlPanel: Invalid degree input for Gripper.");
|
||||
return;
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// Upload button (code-created)
|
||||
// -------------------------
|
||||
|
||||
private void CreateUploadButtonIfNeeded()
|
||||
{
|
||||
if (_uploadButton != null) return;
|
||||
|
||||
var go = new GameObject("UploadButton");
|
||||
go.transform.SetParent(transform, false);
|
||||
|
||||
var img = go.AddComponent<Image>();
|
||||
img.raycastTarget = true;
|
||||
|
||||
_uploadButton = go.AddComponent<Button>();
|
||||
_uploadButton.onClick.AddListener(OnUploadClicked);
|
||||
|
||||
// Copy Send button look
|
||||
CopyButtonStyle(button, _uploadButton);
|
||||
|
||||
var textGo = new GameObject("Text (TMP)");
|
||||
textGo.transform.SetParent(go.transform, false);
|
||||
_uploadButtonText = textGo.AddComponent<TextMeshProUGUI>();
|
||||
_uploadButtonText.text = "Upload Audio";
|
||||
|
||||
// Copy Send text look
|
||||
CopyTMPStyle(_buttonText, _uploadButtonText);
|
||||
_uploadButtonText.alignment = TextAlignmentOptions.Center;
|
||||
|
||||
// Layout: above Play
|
||||
var rt = go.GetComponent<RectTransform>();
|
||||
rt.anchorMin = new Vector2(0.5f, 0f);
|
||||
rt.anchorMax = new Vector2(0.5f, 0f);
|
||||
rt.pivot = new Vector2(0.5f, 0f);
|
||||
rt.sizeDelta = button != null ? button.GetComponent<RectTransform>().sizeDelta : new Vector2(180f, 40f);
|
||||
rt.anchoredPosition = new Vector2(0f, 110f);
|
||||
|
||||
var trt = textGo.GetComponent<RectTransform>();
|
||||
trt.anchorMin = Vector2.zero;
|
||||
trt.anchorMax = Vector2.one;
|
||||
trt.offsetMin = Vector2.zero;
|
||||
trt.offsetMax = Vector2.zero;
|
||||
|
||||
go.SetActive(false);
|
||||
_gripper.SetAngleAndSendControlLibrary(Mathf.Clamp(degrees, 0f, 180f));
|
||||
}
|
||||
|
||||
private void SetUploadVisible(bool visible)
|
||||
{
|
||||
if (_uploadButton != null && _uploadButton.gameObject.activeSelf != visible)
|
||||
_uploadButton.gameObject.SetActive(visible);
|
||||
}
|
||||
|
||||
private void OnUploadClicked()
|
||||
{
|
||||
if (_speaker == null) return;
|
||||
|
||||
string path = OpenAudioFilePicker();
|
||||
if (string.IsNullOrEmpty(path)) return;
|
||||
|
||||
_speaker.SetAudioFile(path);
|
||||
// If you want to display filename somewhere without the input field,
|
||||
// we can put it in the caption temporarily or add a TMP label in code.
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// Play button (code-created)
|
||||
// -------------------------
|
||||
|
||||
private void CreatePlayButtonIfNeeded()
|
||||
{
|
||||
if (_playButton != null) return;
|
||||
|
||||
var go = new GameObject("PlayButton");
|
||||
go.transform.SetParent(transform, false);
|
||||
|
||||
var img = go.AddComponent<Image>();
|
||||
img.raycastTarget = true;
|
||||
|
||||
_playButton = go.AddComponent<Button>();
|
||||
_playButton.onClick.AddListener(OnPlayClicked);
|
||||
|
||||
// Copy Send button look
|
||||
CopyButtonStyle(button, _playButton);
|
||||
|
||||
var textGo = new GameObject("Text (TMP)");
|
||||
textGo.transform.SetParent(go.transform, false);
|
||||
_playButtonText = textGo.AddComponent<TextMeshProUGUI>();
|
||||
_playButtonText.text = "Play Audio";
|
||||
|
||||
// Copy Send text look
|
||||
CopyTMPStyle(_buttonText, _playButtonText);
|
||||
_playButtonText.alignment = TextAlignmentOptions.Center;
|
||||
|
||||
// Layout: between Upload and Send
|
||||
var rt = go.GetComponent<RectTransform>();
|
||||
rt.anchorMin = new Vector2(0.5f, 0f);
|
||||
rt.anchorMax = new Vector2(0.5f, 0f);
|
||||
rt.pivot = new Vector2(0.5f, 0f);
|
||||
rt.sizeDelta = button != null ? button.GetComponent<RectTransform>().sizeDelta : new Vector2(180f, 40f);
|
||||
rt.anchoredPosition = new Vector2(0f, 60f);
|
||||
|
||||
var trt = textGo.GetComponent<RectTransform>();
|
||||
trt.anchorMin = Vector2.zero;
|
||||
trt.anchorMax = Vector2.one;
|
||||
trt.offsetMin = Vector2.zero;
|
||||
trt.offsetMax = Vector2.zero;
|
||||
|
||||
go.SetActive(false);
|
||||
}
|
||||
|
||||
private void SetPlayVisible(bool visible)
|
||||
{
|
||||
if (_playButton != null && _playButton.gameObject.activeSelf != visible)
|
||||
_playButton.gameObject.SetActive(visible);
|
||||
}
|
||||
|
||||
private void OnPlayClicked()
|
||||
{
|
||||
if (_speaker == null) return;
|
||||
_speaker.PlayAudioOnHardware();
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// File Picker (Editor + builds via SFB)
|
||||
// -------------------------
|
||||
|
||||
private string OpenAudioFilePicker()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return UnityEditor.EditorUtility.OpenFilePanel("Select audio file", "", "wav,mp3,ogg");
|
||||
#else
|
||||
var extensions = new[]
|
||||
{
|
||||
new SFB.ExtensionFilter("Audio Files", "wav", "mp3", "ogg"),
|
||||
new SFB.ExtensionFilter("All Files", "*")
|
||||
};
|
||||
|
||||
string[] paths = SFB.StandaloneFileBrowser.OpenFilePanel("Select audio file", "", extensions, false);
|
||||
return (paths != null && paths.Length > 0) ? paths[0] : "";
|
||||
#endif
|
||||
}
|
||||
|
||||
private void SetCaptionVisible(bool visible)
|
||||
{
|
||||
if (_caption != null && _caption.gameObject.activeSelf != visible)
|
||||
_caption.gameObject.SetActive(visible);
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,14 @@ public class LiveViewModulePanel : MonoBehaviour
|
||||
|
||||
private bool _sliderDragging;
|
||||
private ControlPanel panel;
|
||||
private ModuleBase _lastSelected;
|
||||
private GameObject sensorTextContainer;
|
||||
private readonly System.Collections.Generic.List<TextMeshProUGUI> sensorTextLines = new System.Collections.Generic.List<TextMeshProUGUI>();
|
||||
|
||||
void Start()
|
||||
{
|
||||
CreateSensorTextUI();
|
||||
ApplyRoundedCornersToPanel();
|
||||
|
||||
if (servoAngleSlider != null)
|
||||
{
|
||||
@@ -36,6 +38,7 @@ public class LiveViewModulePanel : MonoBehaviour
|
||||
servoAngleSlider.maxValue = 180f;
|
||||
servoAngleSlider.direction = Slider.Direction.BottomToTop;
|
||||
servoAngleSlider.onValueChanged.AddListener(OnServoSliderChanged);
|
||||
ConfigureSliderForVertical(servoAngleSlider);
|
||||
|
||||
var et = servoAngleSlider.GetComponent<EventTrigger>() ?? servoAngleSlider.gameObject.AddComponent<EventTrigger>();
|
||||
var begin = new EventTrigger.Entry { eventID = EventTriggerType.BeginDrag };
|
||||
@@ -66,6 +69,7 @@ public class LiveViewModulePanel : MonoBehaviour
|
||||
|
||||
if (selected == null)
|
||||
{
|
||||
_lastSelected = null;
|
||||
SetModuleInfo("No module selected");
|
||||
SetServoSectionActive(false);
|
||||
SetModuleControlSectionActive(false);
|
||||
@@ -83,7 +87,6 @@ public class LiveViewModulePanel : MonoBehaviour
|
||||
var display = selected as DisplayModule;
|
||||
var distance = selected as DistanceSensorModule;
|
||||
var imu = selected as IMUSensorModule;
|
||||
var speaker = selected as SpeakerModule;
|
||||
|
||||
if (servo != null)
|
||||
{
|
||||
@@ -117,13 +120,20 @@ public class LiveViewModulePanel : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
// DC or Display both use the same control section
|
||||
if (dc != null || display != null || speaker != null)
|
||||
// DC, Display, or Gripper use the same control section (degrees input + button)
|
||||
var gripper = selected as GripperModule;
|
||||
if (dc != null || display != null || gripper != null)
|
||||
{
|
||||
SetServoSectionActive(false);
|
||||
SetModuleControlSectionActive(true);
|
||||
SetSensorTextActive(false);
|
||||
|
||||
if (selected != _lastSelected)
|
||||
{
|
||||
_lastSelected = selected;
|
||||
panel?.Initialize(selected);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,6 +143,16 @@ public class LiveViewModulePanel : MonoBehaviour
|
||||
SetSensorTextActive(false);
|
||||
}
|
||||
|
||||
void ApplyRoundedCornersToPanel()
|
||||
{
|
||||
var img = GetComponent<Image>();
|
||||
if (img != null && img.sprite == null)
|
||||
{
|
||||
img.sprite = UIRoundedSprite.GetRoundedRectSprite();
|
||||
img.type = Image.Type.Sliced; // 9-slice keeps corners rounded when panel stretches
|
||||
}
|
||||
}
|
||||
|
||||
void SetModuleControlSectionActive(bool active)
|
||||
{
|
||||
if (moduleControlSection == null || panel == null) return;
|
||||
@@ -161,6 +181,59 @@ public class LiveViewModulePanel : MonoBehaviour
|
||||
ServoMotorModule.selectedModule.SetAngleAndSendControlLibrary(value);
|
||||
}
|
||||
|
||||
void ConfigureSliderForVertical(Slider slider)
|
||||
{
|
||||
if (slider == null || servoControlSection == null) return;
|
||||
var sectionRect = servoControlSection.GetComponent<RectTransform>();
|
||||
if (sectionRect != null)
|
||||
EnsureDegreeLabels(sectionRect);
|
||||
}
|
||||
|
||||
void EnsureDegreeLabels(RectTransform sectionRect)
|
||||
{
|
||||
SetDegreeLabel(sectionRect, "0deg", "0", 0, 14);
|
||||
SetDegreeLabel(sectionRect, "180deg", "180", 1, -14);
|
||||
}
|
||||
|
||||
void SetDegreeLabel(RectTransform sectionRect, string goName, string text, float anchorY, float posY)
|
||||
{
|
||||
var t = sectionRect.Find(goName);
|
||||
if (t == null)
|
||||
{
|
||||
var go = new GameObject(goName);
|
||||
go.transform.SetParent(sectionRect, false);
|
||||
var tmp = go.AddComponent<TextMeshProUGUI>();
|
||||
tmp.text = text;
|
||||
tmp.fontSize = 16;
|
||||
tmp.color = Color.white;
|
||||
tmp.alignment = TextAlignmentOptions.MidlineLeft;
|
||||
var r = go.GetComponent<RectTransform>();
|
||||
r.anchorMin = new Vector2(1f, anchorY);
|
||||
r.anchorMax = new Vector2(1f, anchorY);
|
||||
r.pivot = new Vector2(0f, 0.5f);
|
||||
r.anchoredPosition = new Vector2(20, posY);
|
||||
r.sizeDelta = new Vector2(50, 24);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tmp = t.GetComponent<TextMeshProUGUI>();
|
||||
if (tmp != null)
|
||||
{
|
||||
tmp.color = Color.white;
|
||||
tmp.fontSize = 16;
|
||||
}
|
||||
var r = t.GetComponent<RectTransform>();
|
||||
if (r != null)
|
||||
{
|
||||
r.anchorMin = new Vector2(1f, anchorY);
|
||||
r.anchorMax = new Vector2(1f, anchorY);
|
||||
r.pivot = new Vector2(0f, 0.5f);
|
||||
r.anchoredPosition = new Vector2(20, posY);
|
||||
r.sizeDelta = new Vector2(50, 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CreateSensorTextUI()
|
||||
{
|
||||
if (moduleInfoText == null) return;
|
||||
@@ -250,12 +323,11 @@ public class LiveViewModulePanel : MonoBehaviour
|
||||
if (m is DCMotorModule) return "DC";
|
||||
if (m is DisplayModule) return "Display";
|
||||
if (m is HubModule) return "Hub";
|
||||
if (m is PowerModule) return "Power";
|
||||
if (m is PowerModule) return "Battery";
|
||||
if (m is GripperModule) return "Gripper";
|
||||
if (m is DisplayModule) return "Display";
|
||||
if (m is DistanceSensorModule) return "Distance Sensor";
|
||||
if (m is IMUSensorModule) return "IMU Sensor";
|
||||
if (m is SpeakerModule) return "Speaker";
|
||||
return m.GetType().Name;
|
||||
}
|
||||
|
||||
|
||||
8
Assets/Materials.meta
Normal file
8
Assets/Materials.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ffba4c85108684a0389509888dbb6582
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/Materials/ConcreteWall.mat
Normal file
39
Assets/Materials/ConcreteWall.mat
Normal file
@@ -0,0 +1,39 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: ConcreteWall
|
||||
m_Shader: {fileID: 4800000, guid: 0335a1d8a6f92a5418f172da855570ad, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _Grid:
|
||||
m_Texture: {fileID: 2800000, guid: 28d78c5517421f047b88352f3b18e8e7, type: 3}
|
||||
m_Scale: {x: 3, y: 3}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _Falloff: 50
|
||||
- _GridScale: 3
|
||||
- _OverlayAmount: 0.876
|
||||
- __dirty: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.4745098, g: 0.4745098, b: 0.4745098, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
8
Assets/Materials/ConcreteWall.mat.meta
Normal file
8
Assets/Materials/ConcreteWall.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
110
Assets/Materials/DarkGreyPlane.mat
Normal file
110
Assets/Materials/DarkGreyPlane.mat
Normal file
@@ -0,0 +1,110 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: DarkGreyPlane
|
||||
m_Shader: {fileID: 4800000, guid: f7ada0af4f174f0694ca6a487b8f543d, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _AlphaTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Cube:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _FaceTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Grid:
|
||||
m_Texture: {fileID: 2800000, guid: 42371d4bc75f5ec43bac646ab93992f9, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OutlineTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _Bevel: 0.5
|
||||
- _BevelClamp: 0
|
||||
- _BevelOffset: 0
|
||||
- _BevelRoundness: 0
|
||||
- _BevelWidth: 0
|
||||
- _BumpFace: 0.5
|
||||
- _BumpOutline: 0.5
|
||||
- _CullMode: 0
|
||||
- _EnableExternalAlpha: 0
|
||||
- _FaceDilate: 0
|
||||
- _FaceShininess: 0
|
||||
- _FaceUVSpeedX: 0
|
||||
- _FaceUVSpeedY: 0
|
||||
- _Falloff: 50
|
||||
- _GlowInner: 0.05
|
||||
- _GlowOffset: 0
|
||||
- _GlowOuter: 0.05
|
||||
- _GlowPower: 0.75
|
||||
- _GradientScale: 5
|
||||
- _GridScale: 1
|
||||
- _OutlineShininess: 0
|
||||
- _OutlineSoftness: 0
|
||||
- _OutlineUVSpeedX: 0
|
||||
- _OutlineUVSpeedY: 0
|
||||
- _OutlineWidth: 0
|
||||
- _OverlayAmount: 0
|
||||
- _PerspectiveFilter: 0.875
|
||||
- _ScaleRatioA: 1
|
||||
- _ScaleRatioB: 1
|
||||
- _ScaleRatioC: 1
|
||||
- _ScaleX: 1
|
||||
- _ScaleY: 1
|
||||
- _ShaderFlags: 0
|
||||
- _Sharpness: 0
|
||||
- _TextureHeight: 512
|
||||
- _TextureWidth: 512
|
||||
- _VertexOffsetX: 0
|
||||
- _VertexOffsetY: 0
|
||||
- _WeightBold: 0.5
|
||||
- _WeightNormal: 0
|
||||
- __dirty: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.9622642, g: 0.27687788, b: 0.27687788, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EnvMatrixRotation: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _FaceColor: {r: 0.014150947, g: 0.014150947, b: 0.014150947, a: 1}
|
||||
- _Flip: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _GlowColor: {r: 0, g: 1, b: 0, a: 0.5}
|
||||
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _ReflectFaceColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _SpecColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
8
Assets/Materials/DarkGreyPlane.mat.meta
Normal file
8
Assets/Materials/DarkGreyPlane.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Materials/WallPanel.mat
Normal file
31
Assets/Materials/WallPanel.mat
Normal file
@@ -0,0 +1,31 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: WallPanel
|
||||
m_Shader: {fileID: 4800000, guid: 0335a1d8a6f92a5418f172da855570ad, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _Grid:
|
||||
m_Texture: {fileID: 2800000, guid: 42371d4bc75f5ec43bac646ab93992f9, type: 3}
|
||||
m_Scale: {x: 4, y: 4}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Falloff: 50
|
||||
- _GridScale: 2
|
||||
- _OverlayAmount: 0.25
|
||||
- __dirty: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.88, g: 0.85, b: 0.82, a: 1}
|
||||
8
Assets/Materials/WallPanel.mat.meta
Normal file
8
Assets/Materials/WallPanel.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89685fdd28e9649348cebbe3f4081709
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -259,7 +259,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 7397659539795428015, guid: c9bb9c26ce95f4c38b0975e4796d7c84, type: 3}
|
||||
- {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
|
||||
@@ -67,7 +67,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 7397659539795428015, guid: 0a21c9a89ba814d51b7c11d9863939c3, type: 3}
|
||||
- {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -210,7 +210,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 7397659539795428015, guid: 0a21c9a89ba814d51b7c11d9863939c3, type: 3}
|
||||
- {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -302,3 +302,4 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 784f95ab01dbf4561a8608c4b0d20705, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: '::'
|
||||
displayText:
|
||||
|
||||
@@ -79,6 +79,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier: '::'
|
||||
objectDetected: 0
|
||||
distanceMeters: 0
|
||||
infoLines: []
|
||||
--- !u!1 &5041994602013865196
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -146,7 +147,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 7397659539795428015, guid: 7e681772ef5614e68a73639cbbae6f05, type: 3}
|
||||
- {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
|
||||
@@ -122,7 +122,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 7397659539795428015, guid: ff94de509dce74d96bc3d1e8d35c56a7, type: 3}
|
||||
- {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -234,7 +234,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 7397659539795428015, guid: 4ab1ba74d3fd045f0a6d3d2b6451892b, type: 3}
|
||||
- {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -377,7 +377,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 7397659539795428015, guid: 4ab1ba74d3fd045f0a6d3d2b6451892b, type: 3}
|
||||
- {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
|
||||
@@ -67,7 +67,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 7397659539795428015, guid: 649bbc984493b417e91518e26718e83c, type: 3}
|
||||
- {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
|
||||
@@ -51,7 +51,7 @@ PrefabInstance:
|
||||
- target: {fileID: 4210207941902691209, guid: 4b60ff46518f54cdea157ba10a27703b, type: 3}
|
||||
propertyPath: 'm_Materials.Array.data[0]'
|
||||
value:
|
||||
objectReference: {fileID: 7397659539795428015, guid: c9bb9c26ce95f4c38b0975e4796d7c84, type: 3}
|
||||
objectReference: {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
- target: {fileID: 4339017592679235832, guid: 4b60ff46518f54cdea157ba10a27703b, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0.0000024074689
|
||||
@@ -143,7 +143,7 @@ PrefabInstance:
|
||||
- target: {fileID: 8899048465141289349, guid: 4b60ff46518f54cdea157ba10a27703b, type: 3}
|
||||
propertyPath: 'm_Materials.Array.data[0]'
|
||||
value:
|
||||
objectReference: {fileID: 7397659539795428015, guid: c9bb9c26ce95f4c38b0975e4796d7c84, type: 3}
|
||||
objectReference: {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_RemovedComponents:
|
||||
- {fileID: 6143875053036137561, guid: 4b60ff46518f54cdea157ba10a27703b, type: 3}
|
||||
m_RemovedGameObjects: []
|
||||
|
||||
@@ -67,7 +67,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 7397659539795428015, guid: c9bb9c26ce95f4c38b0975e4796d7c84, type: 3}
|
||||
- {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -178,7 +178,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 7397659539795428015, guid: c9bb9c26ce95f4c38b0975e4796d7c84, type: 3}
|
||||
- {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
|
||||
@@ -183,6 +183,12 @@ public class TopologyBuilder : MonoBehaviour
|
||||
}
|
||||
servo.InitialSetAngle(module.Degree);
|
||||
}
|
||||
else if (parsedType == ModuleType.GRIPPER)
|
||||
{
|
||||
var gripper = instance.GetComponent<GripperModule>();
|
||||
if (gripper != null)
|
||||
gripper.InitialSetAngle(module.Degree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -196,6 +196,10 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: hub_module_mmmf_unity
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1797760339730403953, guid: 78fb54ff1ce8d48b9886d9638992bd2e, type: 3}
|
||||
propertyPath: 'm_Materials.Array.data[0]'
|
||||
value:
|
||||
objectReference: {fileID: 2100000, guid: 66bb025986bd66c479f0fe7e007798b0, type: 2}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects:
|
||||
|
||||
@@ -8,14 +8,15 @@ public abstract class ModuleBase : MonoBehaviour
|
||||
|
||||
public void SendToControlLibrary(string moduleType, float currentAngle)
|
||||
{
|
||||
int angleRounded = Mathf.RoundToInt(currentAngle);
|
||||
var json = "";
|
||||
if (moduleType.Contains("Servo"))
|
||||
if (moduleType.Contains("Servo") || moduleType == "Gripper")
|
||||
{
|
||||
json = JsonUtility.ToJson(new ServoCommand
|
||||
{
|
||||
ModuleId = moduleID,
|
||||
Type = moduleType,
|
||||
TargetAngle = currentAngle
|
||||
TargetAngle = angleRounded
|
||||
});
|
||||
}
|
||||
else if(moduleType == "DC")
|
||||
@@ -29,7 +30,7 @@ public abstract class ModuleBase : MonoBehaviour
|
||||
{
|
||||
ModuleId = moduleID,
|
||||
Type = moduleType,
|
||||
RotateByDegrees = Math.Abs(currentAngle),
|
||||
RotateByDegrees = Math.Abs(angleRounded),
|
||||
Direction = direction
|
||||
});
|
||||
}
|
||||
@@ -38,7 +39,7 @@ public abstract class ModuleBase : MonoBehaviour
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (0 != ControlLibrary.send_angle_control(Int32.Parse(moduleID), (int)currentAngle))
|
||||
if (0 != ControlLibrary.send_angle_control(Int32.Parse(moduleID), angleRounded))
|
||||
{
|
||||
Debug.Log("Control library exited with error");
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"Modules":[{"Id":"battery1","Type":"Battery","Degree":null},{"Id":"servo1","Type":"Servo1","Degree":45},{"Id":"servo2","Type":"Servo2","Degree":60},{"Id":"servo3","Type":"Servo1","Degree":90},{"Id":"servo4","Type":"Servo2","Degree":45},{"Id":"servo5","Type":"Servo1","Degree":120},{"Id":"servo6","Type":"Servo2","Degree":30},{"Id":"endModule","Type":"DC","Degree":null}],"Connections":[{"FromModuleId":"battery1","ToModuleId":"servo1","FromSocket":"MaleSocket","ToSocket":"BodySocket","Orientation":0},{"FromModuleId":"servo1","ToModuleId":"servo2","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":90},{"FromModuleId":"servo2","ToModuleId":"servo3","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":0},{"FromModuleId":"servo3","ToModuleId":"servo4","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":90},{"FromModuleId":"servo4","ToModuleId":"servo5","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":0},{"FromModuleId":"servo5","ToModuleId":"servo6","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":90},{"FromModuleId":"servo6","ToModuleId":"endModule","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":0}]}
|
||||
{"Modules":[{"Id":"battery1","Type":"Battery","Degree":null},{"Id":"servo1","Type":"Servo1","Degree":45},{"Id":"servo2","Type":"Servo2","Degree":60},{"Id":"servo3","Type":"Servo1","Degree":90},{"Id":"servo4","Type":"Servo2","Degree":45},{"Id":"servo5","Type":"Servo1","Degree":120},{"Id":"servo6","Type":"Servo2","Degree":30},{"Id":"endModule","Type":"Gripper","Degree":90}],"Connections":[{"FromModuleId":"battery1","ToModuleId":"servo1","FromSocket":"MaleSocket","ToSocket":"BodySocket","Orientation":0},{"FromModuleId":"servo1","ToModuleId":"servo2","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":90},{"FromModuleId":"servo2","ToModuleId":"servo3","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":0},{"FromModuleId":"servo3","ToModuleId":"servo4","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":90},{"FromModuleId":"servo4","ToModuleId":"servo5","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":0},{"FromModuleId":"servo5","ToModuleId":"servo6","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":90},{"FromModuleId":"servo6","ToModuleId":"endModule","FromSocket":"MaleSocket","ToSocket":"FemaleSocket","Orientation":0}]}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,7 @@ public class ServoStraightModule : ServoMotorModule
|
||||
{
|
||||
currentAngle = Mathf.Clamp(angle, 0f, 180f);
|
||||
lastSentAngle = currentAngle;
|
||||
armPivot.localRotation = Quaternion.Euler(currentAngle, 0f, 0f);
|
||||
MoveArmPivot(currentAngle);
|
||||
}
|
||||
|
||||
// public void SetHighlight(bool enabled)
|
||||
|
||||
@@ -98,8 +98,11 @@ Material:
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
@@ -108,6 +111,7 @@ Material:
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.477
|
||||
@@ -122,13 +126,15 @@ Material:
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _XRMotionVectorsPass: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.5110952, g: 0.62652487, b: 0.6886792, a: 1}
|
||||
- _Color: {r: 0.5110952, g: 0.62652487, b: 0.6886792, a: 1}
|
||||
- _BaseColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _Color: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -15,15 +15,15 @@ MonoBehaviour:
|
||||
assetVersion: "2"
|
||||
m_enableWordWrapping: 1
|
||||
m_enableKerning: 1
|
||||
m_enableExtraPadding: 0
|
||||
m_enableExtraPadding: 1
|
||||
m_enableTintAllSprites: 0
|
||||
m_enableParseEscapeCharacters: 1
|
||||
m_EnableRaycastTarget: 1
|
||||
m_GetFontFeaturesAtRuntime: 1
|
||||
m_missingGlyphCharacter: 0
|
||||
m_warningsDisabled: 0
|
||||
m_defaultFontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_defaultFontAssetPath: Fonts & Materials/
|
||||
m_defaultFontAsset: {fileID: 11400000, guid: 5302535af1044152a457ed104f1f4b91, type: 2}
|
||||
m_defaultFontAssetPath: Examples & Extras/Resources/Fonts & Materials/
|
||||
m_defaultFontSize: 36
|
||||
m_defaultAutoSizeMinRatio: 0.5
|
||||
m_defaultAutoSizeMaxRatio: 2
|
||||
|
||||
40
Assets/UIRoundedSprite.cs
Normal file
40
Assets/UIRoundedSprite.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Shared utility for creating a rounded-rectangle sprite used by UI panels and buttons.
|
||||
/// </summary>
|
||||
public static class UIRoundedSprite
|
||||
{
|
||||
private static Sprite _roundedRectSprite;
|
||||
|
||||
/// <summary>
|
||||
/// Returns a cached white rounded-rectangle sprite (9-slice friendly, scales well).
|
||||
/// </summary>
|
||||
public static Sprite GetRoundedRectSprite()
|
||||
{
|
||||
if (_roundedRectSprite != null)
|
||||
return _roundedRectSprite;
|
||||
|
||||
const int size = 64;
|
||||
const int radius = 12;
|
||||
var tex = new Texture2D(size, size);
|
||||
var pixels = new Color32[size * size];
|
||||
float r = radius - 0.5f;
|
||||
for (int y = 0; y < size; y++)
|
||||
for (int x = 0; x < size; x++)
|
||||
{
|
||||
float dx = x < r ? r - x : (x >= size - r ? x - (size - 1 - r) : 0);
|
||||
float dy = y < r ? r - y : (y >= size - r ? y - (size - 1 - r) : 0);
|
||||
float d = Mathf.Sqrt(dx * dx + dy * dy);
|
||||
byte a = (byte)Mathf.Clamp(Mathf.RoundToInt(255 * (1f - Mathf.Clamp01((d - r) / 1.5f))), 0, 255);
|
||||
pixels[y * size + x] = new Color32(255, 255, 255, a);
|
||||
}
|
||||
tex.SetPixels32(pixels);
|
||||
tex.Apply(true, true);
|
||||
tex.filterMode = FilterMode.Bilinear;
|
||||
// Border for 9-slice: keeps corners fixed so they don't stretch on tall/wide panels
|
||||
var border = new Vector4(radius, radius, radius, radius);
|
||||
_roundedRectSprite = Sprite.Create(tex, new Rect(0, 0, size, size), new Vector2(0.5f, 0.5f), 100f, 0, SpriteMeshType.FullRect, border);
|
||||
return _roundedRectSprite;
|
||||
}
|
||||
}
|
||||
2
Assets/UIRoundedSprite.cs.meta
Normal file
2
Assets/UIRoundedSprite.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e21775efe677d4675912399106c399ef
|
||||
@@ -21,7 +21,7 @@ public class ViewBannerUI : MonoBehaviour
|
||||
[Header("Colors")]
|
||||
[SerializeField] private Color bannerBackground = Color.black;
|
||||
[SerializeField] private Color buttonDefault = Color.white;
|
||||
[SerializeField] private Color buttonSelected = Color.white;
|
||||
[SerializeField] private Color buttonSelected = new Color(177f / 255f, 1f, 199f / 255f, 1f); // #B1FFC7
|
||||
[SerializeField] private Color buttonTextColor = Color.black;
|
||||
|
||||
private GameObject _liveViewRoot;
|
||||
@@ -140,7 +140,7 @@ public class ViewBannerUI : MonoBehaviour
|
||||
var image = go.AddComponent<Image>();
|
||||
image.color = buttonDefault;
|
||||
image.raycastTarget = true;
|
||||
image.sprite = CreateRoundedRectSprite();
|
||||
image.sprite = UIRoundedSprite.GetRoundedRectSprite();
|
||||
image.type = Image.Type.Simple;
|
||||
|
||||
var button = go.AddComponent<Button>();
|
||||
@@ -174,34 +174,4 @@ public class ViewBannerUI : MonoBehaviour
|
||||
return image;
|
||||
}
|
||||
|
||||
private static Sprite _roundedRectSprite;
|
||||
|
||||
/// <summary>
|
||||
/// Creates or returns a cached white rounded-rectangle sprite for button backgrounds.
|
||||
/// </summary>
|
||||
private static Sprite CreateRoundedRectSprite()
|
||||
{
|
||||
if (_roundedRectSprite != null)
|
||||
return _roundedRectSprite;
|
||||
|
||||
const int size = 64;
|
||||
const int radius = 12;
|
||||
var tex = new Texture2D(size, size);
|
||||
var pixels = new Color32[size * size];
|
||||
float r = radius - 0.5f;
|
||||
for (int y = 0; y < size; y++)
|
||||
for (int x = 0; x < size; x++)
|
||||
{
|
||||
float dx = x < r ? r - x : (x >= size - r ? x - (size - 1 - r) : 0);
|
||||
float dy = y < r ? r - y : (y >= size - r ? y - (size - 1 - r) : 0);
|
||||
float d = Mathf.Sqrt(dx * dx + dy * dy);
|
||||
byte a = (byte)Mathf.Clamp(Mathf.RoundToInt(255 * (1f - Mathf.Clamp01((d - r) / 1.5f))), 0, 255);
|
||||
pixels[y * size + x] = new Color32(255, 255, 255, a);
|
||||
}
|
||||
tex.SetPixels32(pixels);
|
||||
tex.Apply(true, true);
|
||||
tex.filterMode = FilterMode.Bilinear;
|
||||
_roundedRectSprite = Sprite.Create(tex, new Rect(0, 0, size, size), new Vector2(0.5f, 0.5f));
|
||||
return _roundedRectSprite;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user