Exemplo n.º 1
0
 internal static void UpdateVirtualButtons(ImageTargetAbstractBehaviour it, ConfigData.VirtualButtonData[] vbs)
 {
     for (int i = 0; i < vbs.Length; i++)
     {
         VirtualButtonAbstractBehaviour[] componentsInChildren = it.GetComponentsInChildren <VirtualButtonAbstractBehaviour>();
         bool flag = false;
         for (int j = 0; j < componentsInChildren.Length; j++)
         {
             if (componentsInChildren[j].VirtualButtonName == vbs[i].name)
             {
                 SerializedObject serializedObject = new SerializedObject(componentsInChildren[j]);
                 using (serializedObject.Edit())
                 {
                     componentsInChildren[j].enabled = vbs[i].enabled;
                     VirtualButtonEditor.GetSensitivityProperty(serializedObject).enumValueIndex = (int)vbs[i].sensitivity;
                     componentsInChildren[j].SetPosAndScaleFromButtonArea(new Vector2(vbs[i].rectangle[0], vbs[i].rectangle[1]), new Vector2(vbs[i].rectangle[2], vbs[i].rectangle[3]));
                 }
                 flag = true;
             }
         }
         if (!flag)
         {
             VirtualButtonEditor.AddVirtualButton(it, vbs[i]);
         }
     }
 }
Exemplo n.º 2
0
    private ConfigData CreateDataSetFromTrackables(TrackableBehaviour[] trackables)
    {
        if (trackables == null)
        {
            return(null);
        }
        ConfigData data = new ConfigData();

        foreach (TrackableBehaviour behaviour in trackables)
        {
            if (behaviour is DataSetTrackableBehaviour)
            {
                IEditorDataSetTrackableBehaviour behaviour2 = (DataSetTrackableBehaviour)behaviour;
                string dataSetName   = behaviour2.DataSetName;
                string trackableName = behaviour2.TrackableName;
                if (((dataSetName == "--- EMPTY ---") || (dataSetName == "")) || ((trackableName == "--- EMPTY ---") || (trackableName == "")))
                {
                    UnityEngine.Debug.LogWarning("Ignoring default Trackable for export");
                }
                else if (behaviour2 is ImageTargetAbstractBehaviour)
                {
                    ImageTargetAbstractBehaviour behaviour3 = (ImageTargetAbstractBehaviour)behaviour2;
                    IEditorImageTargetBehaviour  behaviour4 = behaviour3;
                    ConfigData.ImageTargetData   item       = new ConfigData.ImageTargetData {
                        size = behaviour4.GetSize()
                    };
                    VirtualButtonAbstractBehaviour[] componentsInChildren = behaviour3.GetComponentsInChildren <VirtualButtonAbstractBehaviour>();
                    item.virtualButtons = new List <ConfigData.VirtualButtonData>(componentsInChildren.Length);
                    foreach (VirtualButtonAbstractBehaviour behaviour5 in componentsInChildren)
                    {
                        Vector2 vector;
                        Vector2 vector2;
                        if (behaviour5.CalculateButtonArea(out vector, out vector2))
                        {
                            ConfigData.VirtualButtonData  data3      = new ConfigData.VirtualButtonData();
                            IEditorVirtualButtonBehaviour behaviour6 = behaviour5;
                            data3.name        = behaviour6.VirtualButtonName;
                            data3.enabled     = behaviour6.enabled;
                            data3.rectangle   = new Vector4(vector.x, vector.y, vector2.x, vector2.y);
                            data3.sensitivity = behaviour6.SensitivitySetting;
                            item.virtualButtons.Add(data3);
                        }
                    }
                    data.SetImageTarget(item, behaviour4.TrackableName);
                }
                else if (behaviour2 is MultiTargetAbstractBehaviour)
                {
                    UnityEngine.Debug.Log("Multi Targets not exported.");
                }
                else if (behaviour2 is CylinderTargetAbstractBehaviour)
                {
                    UnityEngine.Debug.Log("Cylinder Targets not exported.");
                }
            }
        }
        return(data);
    }
Exemplo n.º 3
0
    private static void DetectDuplicates(ImageTargetAbstractBehaviour it)
    {
        IEditorImageTargetBehaviour behaviour = it;

        VirtualButtonAbstractBehaviour[] componentsInChildren = it.GetComponentsInChildren <VirtualButtonAbstractBehaviour>();
        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            for (int j = i + 1; j < componentsInChildren.Length; j++)
            {
                if (componentsInChildren[i].VirtualButtonName == componentsInChildren[j].VirtualButtonName)
                {
                    Debug.LogError("Duplicate virtual buttons with name '" + componentsInChildren[i].VirtualButtonName + "' detected in Image Target '" + behaviour.TrackableName + "'.");
                }
            }
        }
    }
Exemplo n.º 4
0
 private static void DetectDuplicates(ImageTargetAbstractBehaviour it)
 {
     VirtualButtonAbstractBehaviour[] componentsInChildren = it.GetComponentsInChildren <VirtualButtonAbstractBehaviour>();
     for (int i = 0; i < componentsInChildren.Length; i++)
     {
         for (int j = i + 1; j < componentsInChildren.Length; j++)
         {
             if (componentsInChildren[i].VirtualButtonName == componentsInChildren[j].VirtualButtonName)
             {
                 Debug.LogError(string.Concat(new string[]
                 {
                     "Duplicate virtual buttons with name '",
                     componentsInChildren[i].VirtualButtonName,
                     "' detected in Image Target '",
                     it.TrackableName,
                     "'."
                 }));
             }
         }
     }
 }
 public static void UpdateVirtualButtons(ImageTargetAbstractBehaviour it, ConfigData.VirtualButtonData[] vbs)
 {
     for (int i = 0; i < vbs.Length; i++)
     {
         IEditorVirtualButtonBehaviour[] componentsInChildren = it.GetComponentsInChildren <VirtualButtonAbstractBehaviour>();
         bool flag = false;
         for (int j = 0; j < componentsInChildren.Length; j++)
         {
             if (componentsInChildren[j].VirtualButtonName == vbs[i].name)
             {
                 componentsInChildren[j].enabled = vbs[i].enabled;
                 componentsInChildren[j].SetSensitivitySetting(vbs[i].sensitivity);
                 componentsInChildren[j].SetPosAndScaleFromButtonArea(new Vector2(vbs[i].rectangle[0], vbs[i].rectangle[1]), new Vector2(vbs[i].rectangle[2], vbs[i].rectangle[3]));
                 flag = true;
             }
         }
         if (!flag)
         {
             AddVirtualButton(it, vbs[i]);
         }
     }
 }