FarmObject.Initialize C# (CSharp) 메소드

Initialize() 공개 메소드

public Initialize ( string url ) : IEnumerator
url string
리턴 IEnumerator
    public IEnumerator Initialize(string url)
    {
        float x, y, z;
        float length, width, height;
        string name = "Unnamed";
        Vector3 scale, position;

        // Query
        if (!DataManager.dataManager.databaseMirror.ContainsKey (url))
        {
            yield return DataManager.dataManager.StartCoroutine("SingleQuery", url);
        }
        node2 = DataManager.dataManager.databaseMirror[url];
        myURL = url.Replace(System.Environment.NewLine, "");;

        // Setup
        // Get node contents

        x = node2 ["x"].AsFloat;
        z = node2 ["y"].AsFloat;
        y = node2 ["z"].AsFloat;
        length = node2 ["length"].AsFloat;
        width = node2 ["width"].AsFloat;
        height = node2 ["height"].AsFloat;
        if (node2["name"].Value != "null")
        {
            name = node2 ["name"].Value;
        }

        // Set object position, scale, parent, name
        // Set Name
        gameObject.name = name;
        // Set Scale
        scale = new Vector3 (length, height, width);
        transform.localScale = scale;
        // Set Parent gameObject (transform)
        transform.SetParent (parentTransform);
        // Set Position
        Vector3 plScale = transform.parent.lossyScale;
        position = new Vector3 (x / plScale.x, y / plScale.y, z / plScale.z);
        if (isUnityPrimitive)
        {
            Vector3 primitiveOffset = new Vector3(transform.localScale.x*0.5f - 0.5f, transform.localScale.y*0.5f - 0.5f, transform.localScale.z*0.5f - 0.5f);
            position += primitiveOffset;
        }
        transform.localPosition = position;

        // Load Tray / Children, and Resources
        yield return StartCoroutine (LoadResources ());

        if (isTray (myURL))
        {
            isTrayObject = true;
            yield return StartCoroutine(LoadTray ());
        }

        JSONArray children = node2["children"].AsArray;
        foreach (JSONNode child in children)
        {
            yield return StartCoroutine(LoadChild (child));
        }
        // Return
        yield return null;
    }