示例#1
0
 public void ResetTaggedObjects()
 {
     foreach (UserEditableObject ueo in GetMatchingTaggedObjects())
     {
         SimpleJSON.JSONClass obj = JsonUtil.GetUeoBaseProps(new SimpleJSON.JSONClass(), ueo, SceneSerializationType.Instance);
         UserEditableObject   u2  = LevelBuilderObjectManager.inst.PlaceObject(obj, SceneSerializationType.Instance);         // object is now fresh and new.
         u2.OnLevelBuilderObjectCreated();
         u2.OnGameStarted();
         Destroy(ueo.gameObject);
     }
 }
示例#2
0
    // Freshly populate the placed objects
//	public List<LevelBuilderSelectableObject> GetPlacedObjects(SceneSerializationType type){
//		LevelBuilderSelectableObject
//		return ueos;
//	}

    public UserEditableObject PlaceObject(SimpleJSON.JSONClass N, SceneSerializationType type, int uuid = -1)
    {
//		Debug.Log("placing:"+N["name"]);
        GameObject objToPlace     = GetPrefabInstanceFromName(N["name"].Value);
        bool       objActiveState = true;

        if (N.GetKeys().Contains("active"))
        {
//			Debug.Log("obj active;"+N["active"].ToString());
            objActiveState = N["active"].AsBool;             // if the object has this information, it might have been inactive when it was serialized.
        }
        if (objToPlace == null)
        {
            Debug.Log("<color=red>obj null</color>:" + N["name"]);
            return(null);
        }
        objToPlace.transform.position = JsonUtil.GetRealPositionFromTruncatedPosition(N);
//		objToPlace.name += Random.Range(0,100000);
        objToPlace.transform.rotation = JsonUtil.GetRealRotationFromJsonRotation(N);


        SimpleJSON.JSONClass props = (SimpleJSON.JSONClass)N["properties"];
        UserEditableObject   ueo   = objToPlace.GetComponent <UserEditableObject>();

        if (uuid != -1)
        {
            props[UserEditableObject.uuidKey].AsInt = uuid;
        }
        else if (N.GetKeys().Contains(UserEditableObject.uuidKey))
        {
            props[UserEditableObject.uuidKey].AsInt = N[UserEditableObject.uuidKey].AsInt;
        }

        ueo.OnLevelBuilderObjectCreated();
        ueo.SetProperties(props);

        if (LevelBuilder.inst.levelBuilderIsShowing)
        {
            ueo.OnLevelBuilderObjectPlaced();
        }
        if (!objActiveState)
        {
            objToPlace.SetActive(objActiveState);
        }
//		Debug.Log("Built;"+ueo.name+"at :"+ueo.transform.position);
        return(ueo);
    }