Exemple #1
0
    private void AddPrefabToScene(FlashOptions op, Vector3 point)
    {
        //CheckModuleExist();
        GameObject parent;

        switch (op)
        {
        case FlashOptions.Spawner:
            parent = GameObject.Find("SpawnerPoints");
            //InstantiatePrefab(spawnerPrefab, point, parent);
            InstantiatePrefab(spawnerName, point, parent);
            break;

        case FlashOptions.Destination:
            parent = GameObject.Find("DestinationPoints");
            //InstantiatePrefab(destinationPrefab, point, parent);
            InstantiatePrefab(destinationName, point, parent);
            break;
        }
    }
Exemple #2
0
 /// <summary>
 /// Get parameters and materials
 /// </summary>
 public override void BeforeCalculate()
 {
     //get port
     feeds = new List <MaterialObject>();
     foreach (var port in UnitOp.Ports)
     {
         if (port.Value.ComponentName.StartsWith("feed") && ((CapeMaterialPort)port.Value).IsConnected())
         {
             feeds.Add(((CapeMaterialPort)port.Value).Material.Duplicate());
         }
     }
     energyPort = (CapeEnergyPort)UnitOp.Ports["energy"];
     //get parameters
     flashOption = (FlashOptions)(CapeOptionParameter)UnitOp.Parameters["FlashOption"];
     T           = ((CapeRealParameter)UnitOp.Parameters["T"]).value;
     P           = ((CapeRealParameter)UnitOp.Parameters["P"]).value;
     heatduty    = ((CapeRealParameter)UnitOp.Parameters["Heatduty"]).value;
     if (energyPort.IsConnected())
     {
         heatduty += energyPort.Work;
     }
     vaporFraction = ((CapeRealParameter)UnitOp.Parameters["VaporFraction"]).value;
 }
Exemple #3
0
    public override void OnInspectorGUI()
    {
        GUI.color = Color.gray;
        DrawDefaultInspector();
        //creator = target as FlashCreator;
        if (adding || editing)
        {
            if (adding)
            {
                GUI.color = Color.green;
                GUILayout.Label("Choose one of the prefabs:");

                GUI.color = Color.white;
                op        = (FlashOptions)EditorGUILayout.EnumPopup("Prefab to create:", op);
                GUILayout.Space(10);

                GUILayout.FlexibleSpace();
                GUI.color = Color.yellow;
                if (GUILayout.Button("Back"))
                {
                    creator.ReleaseEditObject();
                    editing = false;
                    adding  = false;
                }
            }

            if (editing)
            {
                GUI.color = Color.green;
                GUILayout.Label("Select an existing spawner or destination");
                GUILayout.Label("in the scene to edit the position...");

                ShowProperties();

                GUILayout.FlexibleSpace();
                GUI.color = Color.red;
                if (GUILayout.Button("Remove"))
                {
                    var option = EditorUtility.DisplayDialogComplex(
                        "Spawners and Destinations",
                        "Do you want to remove?",
                        "Yes",
                        "No",
                        "Cancel");
                    if (option == 0)
                    {
                        creator.RemoveEditObject();
                        FindSpawnersAndDestinations();
                        editing = false;
                    }
                }

                GUILayout.FlexibleSpace();
                GUI.color = Color.white;
                if (GUILayout.Button("Undo"))
                {
                    var option = EditorUtility.DisplayDialogComplex(
                        "Spawners and Destinations",
                        "Do you want to undo your changes?",
                        "Yes",
                        "No",
                        "Cancel");
                    if (option == 0)
                    {
                        creator.UndoChanges();
                    }
                }

                GUILayout.FlexibleSpace();
                GUI.color = Color.yellow;
                if (GUILayout.Button("Save and go back"))
                {
                    creator.ReleaseEditObject();
                    editing = false;
                }
            }
        }
        else
        {
            GUILayout.Label("Start by choosing one of the options:");
            GUI.color = Color.green;
            if (GUILayout.Button("Add"))
            {
                adding = true;
            }
            GUILayout.Space(10);

            GUI.color = Color.green;
            if (GUILayout.Button("Edit"))
            {
                FindSpawnersAndDestinations();
                editing = true;
            }

            GUILayout.FlexibleSpace();

            GUI.color = Color.white;
            GUILayout.Label("Press this button to exit 'Pedestrian Editor'");
            GUI.color = Color.yellow;
            if (GUILayout.Button("Exit"))
            {
                editing = false;
                DestroyImmediate(creator.gameObject);
                Selection.activeGameObject = GameObject.Find(moduleName);
            }
        }
    }