コード例 #1
0
    /// <summary>
    /// Adds an XR Item to the world scene.
    /// </summary>
    /// <param name="id">The unique id of the XR Item.</param>
    /// <param name="lat">The latitude location of the XR Item.</param>
    /// <param name="lon">The longitude location of the XR Item.</param>
    /// <param name="heading">The euler heading (in degrees) of the XR Item, relative to the origin normal.</param>
    /// <param name="pitch">The euler pitch rotation (in degrees) of the XR Item, relative to the origin normal.</param>
    public void AddItem(string type, string id, double lat, double y, double lon, double heading, double pitch)
    {
        // Get prefab to use
        string     path   = "P_" + type; // "P" means "prefab" here
        GameObject prefab = Resources.Load(path) as GameObject;

        // Create new XR Item & set its location + rotation
        GameObject itemGO = Instantiate(prefab);
        XRItem     item   = itemGO.GetComponent <XRItem>();

        item.SetId(id);
        item.SetLocation(lat, y, lon);
        // // TP // makes so placement does not have specific rotation as camera unless placing a camera object
        if (!type.Contains("camera"))
        {
            item.SetRotation(0, 0);
        }
        else
        {
            item.SetRotation(heading, pitch);
        }

        // Reposition
        item.Reposition();

        // Add to dictionaries
        Items[id] = item;

        // TP //
        if (EditorToggleButton.Shared.waitingForDuplication)
        {
            EditorToggleButton.Shared.OnDuplication(id, item);
            EditorToggleButton.Shared.waitingForDuplication = false; // reset
        }
    }
コード例 #2
0
    /// <summary>
    /// Adds an XR Item to the world scene.
    /// </summary>
    /// <param name="id">The unique id of the XR Item.</param>
    /// <param name="lat">The latitude location of the XR Item.</param>
    /// <param name="lon">The longitude location of the XR Item.</param>
    /// <param name="heading">The euler heading (in degrees) of the XR Item, relative to the origin normal.</param>
    /// <param name="pitch">The euler pitch rotation (in degrees) of the XR Item, relative to the origin normal.</param>
    public void AddItem(string type, string id, double lat, double lon, double heading, double pitch)
    {
        // Get prefab to use
        string     path   = "P_" + type; // "P" means "prefab" here
        GameObject prefab = Resources.Load(path) as GameObject;

        // Create new XR Item & set its location + rotation
        GameObject itemGO = Instantiate(prefab);
        XRItem     item   = itemGO.GetComponent <XRItem>();

        item.SetId(id);
        item.SetLocation(lat, lon);
        item.SetRotation(heading, pitch);

        // Reposition
        item.Reposition();

        // Add to dictionaries
        Items[id] = item;
    }