コード例 #1
0
    public void OnActionPointsChanged(object sender, EventArgs eventArgs) {
        foreach (Transform t in ActionPointsList.transform) {
            Destroy(t.gameObject);
        }
        foreach (Base.ActionPoint actionPoint in Base.Scene.Instance.GetAllGlobalActionPoints()) {
            GameObject btnGO = Instantiate(Base.GameManager.Instance.ButtonPrefab, ActionPointsList.transform);
            btnGO.transform.localScale = new Vector3(1, 1, 1);
            Button btn = btnGO.GetComponent<Button>();
            btn.GetComponentInChildren<TMPro.TMP_Text>().text = actionPoint.Data.Name;
            btn.onClick.AddListener(() => ShowActionPoint(actionPoint));

            // Add EventTrigger OnPointerEnter and OnPointerExit - to be able to highlight corresponding AP when hovering over button
            OutlineOnClick APoutline = actionPoint.GetComponent<OutlineOnClick>();
            EventTrigger eventTrigger = btnGO.AddComponent<EventTrigger>();
            // Create OnPointerEnter entry
            EventTrigger.Entry OnPointerEnter = new EventTrigger.Entry {
                eventID = EventTriggerType.PointerEnter
            };
            OnPointerEnter.callback.AddListener((eventData) => APoutline.Highlight());
            eventTrigger.triggers.Add(OnPointerEnter);

            // Create OnPointerExit entry
            EventTrigger.Entry OnPointerExit = new EventTrigger.Entry {
                eventID = EventTriggerType.PointerExit
            };
            OnPointerExit.callback.AddListener((eventData) => APoutline.UnHighlight());
            eventTrigger.triggers.Add(OnPointerExit);
        }
    }
コード例 #2
0
    public override void OnInspectorGUI()
    {
        OutlineOnClick outlineOnClick = target as OutlineOnClick;

        GUI.enabled = false;
        EditorGUILayout.ObjectField("Script:", MonoScript.FromMonoBehaviour((OutlineOnClick)target), typeof(OutlineOnClick), false);
        GUI.enabled = true;

        outlineOnClick.OutlineShaderType = (OutlineOnClick.OutlineType)EditorGUILayout.EnumPopup("Outline Type", outlineOnClick.OutlineShaderType);

        if (outlineOnClick.OutlineShaderType == OutlineOnClick.OutlineType.OnePassShader)
        {
            outlineOnClick.OutlineClickMaterial = (Material)EditorGUILayout.ObjectField("Outline Click Material", outlineOnClick.OutlineClickMaterial, typeof(Material), true);
            outlineOnClick.OutlineHoverMaterial = (Material)EditorGUILayout.ObjectField("Outline Hover Material", outlineOnClick.OutlineHoverMaterial, typeof(Material), true);
        }
        else if (outlineOnClick.OutlineShaderType == OutlineOnClick.OutlineType.TwoPassShader)
        {
            outlineOnClick.OutlineClickFirstPass  = (Material)EditorGUILayout.ObjectField("Outline Click First Pass Material", outlineOnClick.OutlineClickFirstPass, typeof(Material), true);
            outlineOnClick.OutlineClickSecondPass = (Material)EditorGUILayout.ObjectField("Outline Click Second Pass Material", outlineOnClick.OutlineClickSecondPass, typeof(Material), true);
            outlineOnClick.OutlineHoverFirstPass  = (Material)EditorGUILayout.ObjectField("Outline Hover First Pass Material", outlineOnClick.OutlineHoverFirstPass, typeof(Material), true);
            outlineOnClick.OutlineHoverSecondPass = (Material)EditorGUILayout.ObjectField("Outline Hover Second Pass Material", outlineOnClick.OutlineHoverSecondPass, typeof(Material), true);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(outlineOnClick);
        }

        serializedObject.Update();
        DrawPropertiesExcluding(serializedObject, new string[] { "m_Script" });
        serializedObject.ApplyModifiedProperties();
    }
コード例 #3
0
    private void AddActionPointButton(Base.ActionPoint actionPoint)
    {
        ActionButton btn = Instantiate(Base.GameManager.Instance.ButtonPrefab, ActionPointsList.transform).GetComponent <ActionButton>();

        btn.transform.localScale = new Vector3(1, 1, 1);
        btn.SetLabel(actionPoint.Data.Name);
        btn.Button.onClick.AddListener(() => ShowActionPoint(actionPoint));
        btn.ObjectId = actionPoint.Data.Id;
        // Add EventTrigger OnPointerEnter and OnPointerExit - to be able to highlight corresponding AP when hovering over button
        OutlineOnClick APoutline    = actionPoint.GetComponent <OutlineOnClick>();
        EventTrigger   eventTrigger = btn.gameObject.AddComponent <EventTrigger>();

        // Create OnPointerEnter entry
        EventTrigger.Entry OnPointerEnter = new EventTrigger.Entry {
            eventID = EventTriggerType.PointerEnter
        };
        OnPointerEnter.callback.AddListener((eventData) => APoutline.Highlight());
        eventTrigger.triggers.Add(OnPointerEnter);

        // Create OnPointerExit entry
        EventTrigger.Entry OnPointerExit = new EventTrigger.Entry {
            eventID = EventTriggerType.PointerExit
        };
        OnPointerExit.callback.AddListener((eventData) => APoutline.UnHighlight());
        eventTrigger.triggers.Add(OnPointerExit);
    }
コード例 #4
0
    public void UpdateMenu()
    {
        objectName.text        = CurrentObject.Data.Name;
        VisibilitySlider.value = CurrentObject.GetVisibility() * 100;
        foreach (Transform t in DynamicContent.transform)
        {
            Destroy(t.gameObject);
        }
        foreach (ActionPoint actionPoint in CurrentObject.GetActionPoints())
        {
            Button button = GameManager.Instance.CreateButton(DynamicContent.transform, actionPoint.Data.Name);
            button.onClick.AddListener(() => ShowActionPoint(actionPoint));

            // Add EventTrigger OnPointerEnter and OnPointerExit - to be able to highlight corresponding AP when hovering over button
            OutlineOnClick APoutline    = actionPoint.GetComponent <OutlineOnClick>();
            EventTrigger   eventTrigger = button.gameObject.AddComponent <EventTrigger>();
            // Create OnPointerEnter entry
            EventTrigger.Entry OnPointerEnter = new EventTrigger.Entry {
                eventID = EventTriggerType.PointerEnter
            };
            OnPointerEnter.callback.AddListener((eventData) => APoutline.Highlight());
            eventTrigger.triggers.Add(OnPointerEnter);

            // Create OnPointerExit entry
            EventTrigger.Entry OnPointerExit = new EventTrigger.Entry {
                eventID = EventTriggerType.PointerExit
            };
            OnPointerExit.callback.AddListener((eventData) => APoutline.UnHighlight());
            eventTrigger.triggers.Add(OnPointerExit);
        }
    }
コード例 #5
0
    public void CreateModel()
    {
        if (ActionObjectMetadata.ObjectModel == null || ActionObjectMetadata.ObjectModel.Type == IO.Swagger.Model.ObjectModel.TypeEnum.None)
        {
            Model = Instantiate(CubePrefab, Visual.transform);
            Visual.transform.localScale = new Vector3(0.05f, 0.01f, 0.05f);
        }
        else
        {
            switch (ActionObjectMetadata.ObjectModel.Type)
            {
            case IO.Swagger.Model.ObjectModel.TypeEnum.Box:
                Model = Instantiate(CubePrefab, Visual.transform);
                Visual.transform.localScale = TransformConvertor.ROSToUnityScale(new Vector3((float)ActionObjectMetadata.ObjectModel.Box.SizeX, (float)ActionObjectMetadata.ObjectModel.Box.SizeY, (float)ActionObjectMetadata.ObjectModel.Box.SizeZ));
                break;

            case IO.Swagger.Model.ObjectModel.TypeEnum.Cylinder:
                Model = Instantiate(CylinderPrefab, Visual.transform);
                Visual.transform.localScale = new Vector3((float)ActionObjectMetadata.ObjectModel.Cylinder.Radius, (float)ActionObjectMetadata.ObjectModel.Cylinder.Height, (float)ActionObjectMetadata.ObjectModel.Cylinder.Radius);
                break;

            case IO.Swagger.Model.ObjectModel.TypeEnum.Sphere:
                Model = Instantiate(SpherePrefab, Visual.transform);
                Visual.transform.localScale = new Vector3((float)ActionObjectMetadata.ObjectModel.Sphere.Radius, (float)ActionObjectMetadata.ObjectModel.Sphere.Radius, (float)ActionObjectMetadata.ObjectModel.Sphere.Radius);
                break;

            default:
                Model = Instantiate(CubePrefab, Visual.transform);
                Visual.transform.localScale = new Vector3(0.05f, 0.01f, 0.05f);
                break;
            }
        }
        if (IsRobot())
        {
            Model.tag = "Robot";
        }
        gameObject.GetComponent <BindParentToChild>().ChildToBind = Model;
        Model.GetComponent <OnClickCollider>().Target             = gameObject;
        Model.transform.localScale = new Vector3(1, 1, 1);
        modelRenderer  = Model.GetComponent <Renderer>();
        outlineOnClick = gameObject.GetComponent <OutlineOnClick>();
        outlineOnClick.InitRenderers(new List <Renderer>()
        {
            modelRenderer
        });
    }
コード例 #6
0
    public override void UpdateMenu()
    {
        base.UpdateMenu();



        overrides.Clear();
        createAPBtn.SetInteractivity(CurrentObject.ActionObjectMetadata.HasPose);

        foreach (Parameter param in CurrentObject.ObjectParameters.Values.ToList())
        {
            ActionObjectParameterOverride overrideParam = Instantiate(ParameterOverridePrefab, Parameters.transform).GetComponent <ActionObjectParameterOverride>();
            overrideParam.transform.SetAsLastSibling();
            overrideParam.Init(param.GetStringValue(), false, param.ParameterMetadata, CurrentObject.Data.Id);
            Debug.LogError(CurrentObject.Overrides.Count);
            if (CurrentObject.Overrides.TryGetValue(param.Name, out Parameter p))
            {
                Debug.LogError(p);
                overrideParam.SetValue(p.GetStringValue(), true);
            }
            overrides[param.Name] = overrideParam;
        }

        foreach (ActionPoint actionPoint in CurrentObject.GetActionPoints())
        {
            Button button = GameManager.Instance.CreateButton(ActionPointsList.transform, actionPoint.Data.Name);
            button.onClick.AddListener(() => ShowActionPoint(actionPoint));

            // Add EventTrigger OnPointerEnter and OnPointerExit - to be able to highlight corresponding AP when hovering over button
            OutlineOnClick APoutline    = actionPoint.GetComponent <OutlineOnClick>();
            EventTrigger   eventTrigger = button.gameObject.AddComponent <EventTrigger>();
            // Create OnPointerEnter entry
            EventTrigger.Entry OnPointerEnter = new EventTrigger.Entry {
                eventID = EventTriggerType.PointerEnter
            };
            OnPointerEnter.callback.AddListener((eventData) => APoutline.Highlight());
            eventTrigger.triggers.Add(OnPointerEnter);

            // Create OnPointerExit entry
            EventTrigger.Entry OnPointerExit = new EventTrigger.Entry {
                eventID = EventTriggerType.PointerExit
            };
            OnPointerExit.callback.AddListener((eventData) => APoutline.UnHighlight());
            eventTrigger.triggers.Add(OnPointerExit);
        }
    }
コード例 #7
0
        public override void CreateModel(CollisionModels customCollisionModels = null)
        {
            RobotPlaceholder = Instantiate(RobotPlaceholderPrefab, transform);
            RobotPlaceholder.transform.parent        = transform;
            RobotPlaceholder.transform.localPosition = Vector3.zero;
            RobotPlaceholder.transform.localPosition = Vector3.zero;
            //Model.transform.localScale = new Vector3(0.05f, 0.01f, 0.05f);

            RobotPlaceholder.GetComponent <OnClickCollider>().Target = gameObject;
            robotColliders = RobotPlaceholder.GetComponentsInChildren <Collider>();
            robotRenderers = RobotPlaceholder.GetComponentsInChildren <Renderer>();
            List <Renderer> ren = new List <Renderer>();

            ren.AddRange(robotRenderers);
            outlineOnClick = gameObject.GetComponent <OutlineOnClick>();
            outlineOnClick.InitRenderers(ren);
        }
コード例 #8
0
        public override void CreateModel(CollisionModels customCollisionModels = null)
        {
            RobotPlaceholder = Instantiate(RobotPlaceholderPrefab, transform);
            RobotPlaceholder.transform.parent        = transform;
            RobotPlaceholder.transform.localPosition = Vector3.zero;
            RobotPlaceholder.transform.localPosition = Vector3.zero;
            //Model.transform.localScale = new Vector3(0.05f, 0.01f, 0.05f);

            RobotPlaceholder.GetComponent <OnClickCollider>().Target = gameObject;

            robotColliders.Clear();
            robotRenderers.Clear();
            robotRenderers.AddRange(RobotPlaceholder.GetComponentsInChildren <Renderer>());
            robotColliders.AddRange(RobotPlaceholder.GetComponentsInChildren <Collider>());
            outlineOnClick = gameObject.GetComponent <OutlineOnClick>();
            outlineOnClick.InitRenderers(robotRenderers);
            outlineOnClick.OutlineShaderType = OutlineOnClick.OutlineType.OnePassShader;
            outlineOnClick.InitGizmoMaterials();
        }
コード例 #9
0
    /// <summary>
    /// Creates button in orientations dynamic list with orientation's arrow highlight on hover
    /// </summary>
    /// <param name="orientation"></param>
    private void CreateOrientationBtn(NamedOrientation orientation)
    {
        ActionButton orientationButton = CreateBtn(OrientationsDynamicList.transform, orientation.Id, orientation.Name, () => OpenDetailMenu(orientation));

        // Add EventTrigger OnPointerEnter and OnPointerExit - to be able to highlight corresponding orientation when hovering over button
        OutlineOnClick orientationOutline = CurrentActionPoint.GetOrientationVisual(orientation.Id).GetComponent <OutlineOnClick>();
        EventTrigger   eventTrigger       = orientationButton.gameObject.AddComponent <EventTrigger>();

        // Create OnPointerEnter entry
        EventTrigger.Entry onPointerEnter = new EventTrigger.Entry {
            eventID = EventTriggerType.PointerEnter
        };
        onPointerEnter.callback.AddListener((eventData) => orientationOutline.Highlight());
        eventTrigger.triggers.Add(onPointerEnter);

        // Create OnPointerExit entry
        EventTrigger.Entry onPointerExit = new EventTrigger.Entry {
            eventID = EventTriggerType.PointerExit
        };
        onPointerExit.callback.AddListener((eventData) => orientationOutline.UnHighlight());
        eventTrigger.triggers.Add(onPointerExit);
    }
コード例 #10
0
        public override void CreateModel(CollisionModels customCollisionModels = null)
        {
            RobotPlaceholder = Instantiate(RobotPlaceholderPrefab, transform);
            RobotPlaceholder.transform.parent        = transform;
            RobotPlaceholder.transform.localPosition = Vector3.zero;
            RobotPlaceholder.transform.localPosition = Vector3.zero;

            RobotPlaceholder.GetComponent <OnClickCollider>().Target = gameObject;

            robotColliders.Clear();
            robotRenderers.Clear();
            robotRenderers.AddRange(RobotPlaceholder.GetComponentsInChildren <Renderer>());
            robotColliders.AddRange(RobotPlaceholder.GetComponentsInChildren <Collider>());
            Colliders      = robotColliders;
            outlineOnClick = gameObject.GetComponent <OutlineOnClick>();
            outlineOnClick.InitRenderers(robotRenderers);
            outlineOnClick.OutlineShaderType = OutlineOnClick.OutlineType.TwoPassShader;
            Target target = GetComponent <Target>();

            if (target != null)
            {
                target.ChangeTarget(RobotPlaceholder);
            }
        }
コード例 #11
0
 protected override void Start()
 {
     base.Start();
     tfGizmo        = Camera.main.GetComponent <TransformGizmo>();
     outlineOnClick = GetComponent <OutlineOnClick>();
 }
コード例 #12
0
    public override void CreateModel(CollisionModels customCollisionModels = null)
    {
        if (ActionObjectMetadata.ObjectModel == null || ActionObjectMetadata.ObjectModel.Type == IO.Swagger.Model.ObjectModel.TypeEnum.None)
        {
            Model = Instantiate(CubePrefab, Visual.transform);
            Model.transform.localScale = new Vector3(0.05f, 0.01f, 0.05f);
        }
        else
        {
            switch (ActionObjectMetadata.ObjectModel.Type)
            {
            case IO.Swagger.Model.ObjectModel.TypeEnum.Box:
                Model = Instantiate(CubePrefab, Visual.transform);

                if (customCollisionModels == null)
                {
                    Model.transform.localScale = TransformConvertor.ROSToUnityScale(new Vector3((float)ActionObjectMetadata.ObjectModel.Box.SizeX, (float)ActionObjectMetadata.ObjectModel.Box.SizeY, (float)ActionObjectMetadata.ObjectModel.Box.SizeZ));
                }
                else
                {
                    foreach (IO.Swagger.Model.Box box in customCollisionModels.Boxes)
                    {
                        if (box.Id == ActionObjectMetadata.Type)
                        {
                            Model.transform.localScale = TransformConvertor.ROSToUnityScale(new Vector3((float)box.SizeX, (float)box.SizeY, (float)box.SizeZ));
                            break;
                        }
                    }
                }
                break;

            case IO.Swagger.Model.ObjectModel.TypeEnum.Cylinder:
                Model = Instantiate(CylinderPrefab, Visual.transform);
                if (customCollisionModels == null)
                {
                    Model.transform.localScale = new Vector3((float)ActionObjectMetadata.ObjectModel.Cylinder.Radius, (float)ActionObjectMetadata.ObjectModel.Cylinder.Height / 2, (float)ActionObjectMetadata.ObjectModel.Cylinder.Radius);
                }
                else
                {
                    foreach (IO.Swagger.Model.Cylinder cylinder in customCollisionModels.Cylinders)
                    {
                        if (cylinder.Id == ActionObjectMetadata.Type)
                        {
                            Model.transform.localScale = new Vector3((float)cylinder.Radius, (float)cylinder.Height, (float)cylinder.Radius);
                            break;
                        }
                    }
                }
                break;

            case IO.Swagger.Model.ObjectModel.TypeEnum.Sphere:
                Model = Instantiate(SpherePrefab, Visual.transform);
                if (customCollisionModels == null)
                {
                    Model.transform.localScale = new Vector3((float)ActionObjectMetadata.ObjectModel.Sphere.Radius, (float)ActionObjectMetadata.ObjectModel.Sphere.Radius, (float)ActionObjectMetadata.ObjectModel.Sphere.Radius);
                }
                else
                {
                    foreach (IO.Swagger.Model.Sphere sphere in customCollisionModels.Spheres)
                    {
                        if (sphere.Id == ActionObjectMetadata.Type)
                        {
                            Model.transform.localScale = new Vector3((float)sphere.Radius, (float)sphere.Radius, (float)sphere.Radius);
                            break;
                        }
                    }
                }
                break;

            case ObjectModel.TypeEnum.Mesh:
                MeshImporter.Instance.OnMeshImported += OnModelLoaded;
                MeshImporter.Instance.LoadModel(ActionObjectMetadata.ObjectModel.Mesh, GetId());

                Model = Instantiate(CubePrefab, Visual.transform);
                Model.transform.localScale = new Vector3(0.05f, 0.01f, 0.05f);
                break;

            default:
                Model = Instantiate(CubePrefab, Visual.transform);
                Model.transform.localScale = new Vector3(0.05f, 0.01f, 0.05f);
                break;
            }
        }
        //if (IsRobot()) {
        //    Model.tag = "Robot";
        //}

        gameObject.GetComponent <BindParentToChild>().ChildToBind = Model;
        Collider = Model.GetComponent <Collider>();
        Colliders.Add(Collider);
        Model.GetComponent <OnClickCollider>().Target = gameObject;

        outlineOnClick = gameObject.GetComponent <OutlineOnClick>();

        aoRenderers.Clear();
        aoRenderers.AddRange(Model.GetComponentsInChildren <Renderer>(true));

        outlineOnClick.InitRenderers(aoRenderers);
    }
コード例 #13
0
    public override void CreateModel(CollisionModels customCollisionModels = null)
    {
        if (ActionObjectMetadata.ObjectModel == null || ActionObjectMetadata.ObjectModel.Type == IO.Swagger.Model.ObjectModel.TypeEnum.None)
        {
            Model = Instantiate(CubePrefab, Visual.transform);
            Model.transform.localScale = new Vector3(0.05f, 0.01f, 0.05f);
        }
        else
        {
            switch (ActionObjectMetadata.ObjectModel.Type)
            {
            case IO.Swagger.Model.ObjectModel.TypeEnum.Box:
                Model = Instantiate(CubePrefab, Visual.transform);

                if (customCollisionModels == null)
                {
                    Model.transform.localScale = TransformConvertor.ROSToUnityScale(new Vector3((float)ActionObjectMetadata.ObjectModel.Box.SizeX, (float)ActionObjectMetadata.ObjectModel.Box.SizeY, (float)ActionObjectMetadata.ObjectModel.Box.SizeZ));
                }
                else
                {
                    foreach (IO.Swagger.Model.Box box in customCollisionModels.Boxes)
                    {
                        if (box.Id == ActionObjectMetadata.Type)
                        {
                            Model.transform.localScale = TransformConvertor.ROSToUnityScale(new Vector3((float)box.SizeX, (float)box.SizeY, (float)box.SizeZ));
                            break;
                        }
                    }
                }
                break;

            case IO.Swagger.Model.ObjectModel.TypeEnum.Cylinder:
                Model = Instantiate(CylinderPrefab, Visual.transform);
                if (customCollisionModels == null)
                {
                    Model.transform.localScale = new Vector3((float)ActionObjectMetadata.ObjectModel.Cylinder.Radius, (float)ActionObjectMetadata.ObjectModel.Cylinder.Height / 2, (float)ActionObjectMetadata.ObjectModel.Cylinder.Radius);
                }
                else
                {
                    foreach (IO.Swagger.Model.Cylinder cylinder in customCollisionModels.Cylinders)
                    {
                        if (cylinder.Id == ActionObjectMetadata.Type)
                        {
                            Model.transform.localScale = new Vector3((float)cylinder.Radius, (float)cylinder.Height, (float)cylinder.Radius);
                            break;
                        }
                    }
                }
                break;

            case IO.Swagger.Model.ObjectModel.TypeEnum.Sphere:
                Model = Instantiate(SpherePrefab, Visual.transform);
                if (customCollisionModels == null)
                {
                    Model.transform.localScale = new Vector3((float)ActionObjectMetadata.ObjectModel.Sphere.Radius, (float)ActionObjectMetadata.ObjectModel.Sphere.Radius, (float)ActionObjectMetadata.ObjectModel.Sphere.Radius);
                }
                else
                {
                    foreach (IO.Swagger.Model.Sphere sphere in customCollisionModels.Spheres)
                    {
                        if (sphere.Id == ActionObjectMetadata.Type)
                        {
                            Model.transform.localScale = new Vector3((float)sphere.Radius, (float)sphere.Radius, (float)sphere.Radius);
                            break;
                        }
                    }
                }
                break;

            default:
                Model = Instantiate(CubePrefab, Visual.transform);
                Model.transform.localScale = new Vector3(0.05f, 0.01f, 0.05f);
                break;
            }
        }
        if (IsRobot())
        {
            Model.tag = "Robot";
        }
        gameObject.GetComponent <BindParentToChild>().ChildToBind = Model;
        Collider = Model.GetComponent <Collider>();
        Model.GetComponent <OnClickCollider>().Target = gameObject;
        modelRenderer  = Model.GetComponent <Renderer>();
        modelMaterial  = modelRenderer.material;
        outlineOnClick = gameObject.GetComponent <OutlineOnClick>();
        outlineOnClick.InitRenderers(new List <Renderer>()
        {
            modelRenderer
        });
        Model.AddComponent <GizmoOutlineHandler>().OutlineOnClick = outlineOnClick;
    }
コード例 #14
0
 private void Awake() {
     id = Guid.NewGuid().ToString();
     outlineOnClick = GetComponent<OutlineOnClick>();
 }