Ejemplo n.º 1
0
    private void GenerateMap()
    {
        for (int x = -maxMapBound; x < maxMapBound + 1; x++)
        {
            for (int y = -maxMapBound; y < maxMapBound + 1; y++)
            {
                if ((x != 0 || y != 0) && Random.value < 0.1f)
                {
                    float      resourceType = Random.value * 3.0f;
                    GameObject resource;
                    PrefabUtil prefabUtil = SingletonFactory.GetInstance <PrefabUtil>();

                    if (resourceType < 1.0f)
                    {
                        resource = prefabUtil.treePre;
                    }
                    else if (resourceType < 2.0f)
                    {
                        resource = prefabUtil.stonePre;
                    }
                    else
                    {
                        resource = prefabUtil.ironPre;
                    }

                    Instantiate(resource, new Vector3(x, y, 0), Quaternion.identity);
                }
            }
        }
    }
Ejemplo n.º 2
0
        public SpawnedObjectController SpawnAsController(GameObject prefab, Vector3 position, Quaternion rotation, Transform par = null, System.Action <GameObject> initializeProperties = null, ISpawner optionalSpawnPoint = null)
        {
            var cache = this.FindPrefabCache(prefab);

            if (cache != null)
            {
                var controller = cache.Spawn(position, rotation, par, initializeProperties);
                this.SignalSpawned(controller, optionalSpawnPoint);
                return(controller);
            }
            else
            {
                var obj = PrefabUtil.Create(prefab, position, rotation, par);
                if (obj != null)
                {
                    var controller = obj.AddOrGetComponent <SpawnedObjectController>();
                    controller.Init(this);
                    if (initializeProperties != null)
                    {
                        initializeProperties(obj);
                    }
                    controller.SetSpawned();
                    this.SignalSpawned(controller, optionalSpawnPoint);
                    return(controller);
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Bakes the prefab lightmaps.
        /// </summary>
        /// <param name="prefabs">The <see cref="Array"/> of <see cref="PrefabLightmapData"/>.</param>
        private static void BakePrefabLightmaps(PrefabLightmapData[] prefabs)
        {
            if (prefabs.Length > 0)
            {
                for (int i = 0, length = prefabs.Length; i < length; i++)
                {
                    PrefabLightmapData          data           = prefabs[i];
                    GameObject                  gameObject     = data.gameObject;
                    List <LightmapRendererInfo> rendererInfos  = new List <LightmapRendererInfo>();
                    List <Texture2D>            lightmapColors = new List <Texture2D>();
                    List <Texture2D>            lightmapDirs   = new List <Texture2D>();
                    List <Texture2D>            shadowMasks    = new List <Texture2D>();

                    GenerateLightmapInfo(gameObject, rendererInfos, lightmapColors, lightmapDirs, shadowMasks);

                    data.RendererInfos  = rendererInfos.ToArray();
                    data.LightmapColors = lightmapColors.ToArray();
                    data.LightmapDirs   = lightmapDirs.ToArray();
                    data.ShadowMasks    = shadowMasks.ToArray();

                    // Save prefab.
                    PrefabUtil.SavePrefab(gameObject, ReplacePrefabOptions.ConnectToPrefab);

                    // Apply lightmap.
                    PrefabLightmapData.ApplyStaticLightmap(data);
                }
            }
        }
Ejemplo n.º 4
0
 public Particle emit(string name)
 {
     if (particles_.ContainsKey(name) == false)
     {
         return(null);
     }
     return(PrefabUtil.createInstance(particles_[name]));
 }
Ejemplo n.º 5
0
    void OnGUI()
    {
        GameObject tile = Selection.activeGameObject;

        if (tile == null || !tile.CompareTag("Tile"))
        {
            EditorGUILayout.HelpBox("Select a tile in the hierarchy view to enable Decentraland tile uploader.", MessageType.Warning);
            return;
        }

        GUILayout.Label("\n");
        GUILayout.Label("Configuration\n");

        nodeAddress = EditorGUILayout.TextField("Your Node RPC URL", nodeAddress);
        nodeAuth    = EditorGUILayout.TextField("Node RPC Auth Token", nodeAuth);

        GUILayout.Label("\n");
        GUILayout.Label("\n");
        GUILayout.Label("Editor\n");
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Tile Coordinates");
        GUILayout.Label("X");
        xOffset = EditorGUILayout.IntField(xOffset);
        GUILayout.Label("Y");
        zOffset = EditorGUILayout.IntField(zOffset);

        EditorGUILayout.EndHorizontal();

        // Delete temporal assets
        if (deleteTempFiles && DirUtil.Exists("Assets/_Temp"))
        {
            DirUtil.DeleteFolder("Assets/_Temp");
        }

        if (GUILayout.Button("Publish Selected Tile "))
        {
            var    prefab   = PrefabUtil.CreatePrefabFromActiveGO(tempFolder + "Prefab/");
            var    manifest = AssetBundleEditorUtil.CreateAssetBundle(prefab, "TileBundle", tempFolder + "Bundle/", BuildTarget.WebGL);
            var    bytes    = AssetBundleEditorUtil.GetBytesFromManifest(manifest, tempFolder + "Bundle/");
            string content  = IOHelper.BytesToBase64String(bytes);

            Vector2 index = new Vector2(
                (tile.transform.position.x / TILE_SIZE) + xOffset,
                (tile.transform.position.z / TILE_SIZE) + zOffset
                );

            PublishTile(index, content);
        }

        if (publishError)
        {
            EditorGUILayout.HelpBox("Error publishing tile!", MessageType.Error);
        }
        else
        {
            EditorGUILayout.HelpBox(publishing ? ("Publishing tile at (" + xOffset + "," + zOffset + ")") : (published ? "Published!" : ""), MessageType.Info);
        }
    }
Ejemplo n.º 6
0
        public void Start()
        {
            var spaceshipPrefab = PrefabUtil.Create <SpaceshipController>("GhostSpaceship");

            _ghostSpaceShip       = GameObject.Instantiate(spaceshipPrefab, Spaceship.transform.position + Spaceship.transform.up, Spaceship.transform.rotation);
            _ghostSpaceShip.Input = Spaceship.Input;


            UpdateTopAssaultWeapon();
        }
        private void OnWizardCreate()
        {
            // Check if the character data already exists
            if (AssetDatabase.IsValidFolder(data.RootFolder))
            {
                bool result = EditorUtility.DisplayDialog("Error",
                                                          "A character with the internal name of \"" + data.InternalName +
                                                          "\" already exists. Either edit the existing Character, or delete and restart.",
                                                          "Delete",
                                                          "Cancel");
                if (result)
                {
                    AssetDatabase.DeleteAsset(data.RootFolder);
                }
                else
                {
                    return;
                }
            }

            data.Generate();

            GameObject prefabSource;

            if (_sourceObject == null)
            {
                prefabSource = new GameObject(data.InternalName);
            }
            else
            {
                prefabSource = _sourceObject.gameObject;
            }

            prefabSource.GetOrAddComponent <Character>().InternalName = data.InternalName;

            Object prefab = prefabSource.GetPrefab();

            if (prefab == null)
            {
                prefab = PrefabUtil.CreatePrefab(data.RootFolder, prefabSource);
            }
            else
            {
                AssetUtil.MoveAsset(data.RootFolder, prefab);
            }

            data.Prefab = prefab as GameObject;

            Selection.activeGameObject = prefabSource;

            CharacterEditorWindow.ShowWindow().Target = data;
        }
Ejemplo n.º 8
0
        public override void Start()
        {
            Controller.Input.enabled = true;

            var spaceshipPrefab = PrefabUtil.Create <SpaceshipController>("Spaceship");

            _spaceShip       = GameObject.Instantiate(spaceshipPrefab, Vector3.zero, Quaternion.identity);
            _spaceShip.Input = Controller.Input;
            _spaceShip.StartEngine();

            PrepareCamera();

            Controller.AstroidController.Initialize();
            Controller.UIController.Exit += UIController_Exit;
            Controller.UIController.AbilityController.Changed += AbilityController_Changed;
        }
Ejemplo n.º 9
0
        public static T GetWeapon <T>(Transform parent, string name = "") where T : SpaceshipAssaultWeapon, new()
        {
            T prefab = PrefabUtil.Create <T>(string.IsNullOrEmpty(name) ? typeof(T).Name : name);

            if (prefab == null)
            {
                return(null);
            }

            var weapon = GameObject.Instantiate(prefab);

            weapon.transform.parent        = parent;
            weapon.transform.localPosition = Vector3.zero;
            weapon.transform.localRotation = Quaternion.identity;
            return(weapon);
        }
Ejemplo n.º 10
0
            private SpawnedObjectController CreateCacheInstance(int index)
            {
                var obj = PrefabUtil.Create(this.Prefab, Vector3.zero, Quaternion.identity);

                obj.name = this.ItemName + (index + 1).ToString("000");
                var cntrl = obj.AddComponent <SpawnedObjectController>();

                cntrl.Init(_owner, this.ItemName);

                obj.transform.parent        = _owner.transform;
                obj.transform.localPosition = Vector3.zero;
                obj.transform.rotation      = Quaternion.identity;

                //obj.DeactivateAll();
                obj.SetActive(false);

                return(cntrl);
            }
Ejemplo n.º 11
0
        public static Player Create(PlayerDataContext dataContext)
        {
            GameObject go     = new GameObject(dataContext.UserName);
            Player     player = go.AddComponent <Player>();

            player.SetDataContext(dataContext);

            player.OffsetGO = new GameObject("offset");
            player.OffsetGO.transform.parent        = player.transform;
            player.OffsetGO.transform.localPosition = player.OFFSET;

            GameObject cue = Instantiate(PrefabUtil.Create <GameObject>(dataContext.CuePrefabName, "cue"));

            cue.transform.parent    = player.transform;
            player.Cue              = cue.transform.Find("Spin").Find("Cue").GetComponent <BaseCue>();
            player.Cue.TriggerStay += player.Cue_TriggerStay;

            return(player);
        }
Ejemplo n.º 12
0
        private static bool PreInitializePrefab(VehicleInfo __instance)
        {
            try
            {
                if (__instance?.m_class?.name != ItemClasses.cargoFerryVehicle.name)
                {
                    return(true);
                }

                var oldAi = __instance.GetComponent <CargoShipAI>();
                Object.DestroyImmediate(oldAi);
                var ai = __instance.gameObject.AddComponent <CargoFerryAI>();
                PrefabUtil.TryCopyAttributes(oldAi, ai, false);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(true);
        }
Ejemplo n.º 13
0
        private static bool PreInitializePrefab(global::BuildingInfo __instance)
        {
            try
            {
                if (__instance?.m_class?.name != ItemClasses.cargoFerryFacility.name)
                {
                    return(true);
                }

                var oldAi = __instance.GetComponent <CargoHarborAI>();
                Object.DestroyImmediate(oldAi);
                var ai = (SteamHelper.IsDLCOwned(SteamHelper.DLC.IndustryDLC) &
                          OptionsWrapper <Options> .Options.EnableWarehouseAI)
                    ? __instance.gameObject.AddComponent <CargoFerryWarehouseHarborAI>()
                    : __instance.gameObject.AddComponent <CargoFerryHarborAI>();
                PrefabUtil.TryCopyAttributes(oldAi, ai, false);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(true);
        }
Ejemplo n.º 14
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorHelpers.DrawHeader(Banner);

            if (QuantumConsoleProcessor.TableGenerated || QuantumConsoleProcessor.TableIsGenerating)
            {
                EditorGUILayout.LabelField("Quantum Console Processor Information", EditorStyles.miniBoldLabel);
                if (QuantumConsoleProcessor.TableIsGenerating)
                {
                    EditorGUILayout.LabelField("Command Table Generating...", EditorStyles.miniLabel);
                }
                EditorGUILayout.LabelField($"Commands Loaded: {QuantumConsoleProcessor.LoadedCommandCount}", EditorStyles.miniLabel);
                EditorGUILayout.Space();
            }

            EditorGUILayout.LabelField(new GUIContent("General Settings", "All general and basic settings for the Quantum Console."), EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(_themeProperty, new GUIContent("Theme", "QuantumTheme to use for this Quantum Console."));
            if (_themeProperty.objectReferenceValue)
            {
                GUIContent applyBtnContent = new GUIContent("Apply", "Forces an application of the theme now allowing you to see any GUI changes it would make");
                if (QGUILayout.ButtonAuto(applyBtnContent, EditorStyles.miniButton))
                {
                    Undo.RecordObject(QCInstance, "Applied a theme to the Quantum Console");
                    QCInstance.ApplyTheme((QuantumTheme)_themeProperty.objectReferenceValue, true);
                    PrefabUtil.RecordPrefabInstancePropertyModificationsFullyRecursive(QCInstance.gameObject);
                    EditorUtility.SetDirty(QCInstance);
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.PropertyField(_keyConfigProperty, new GUIContent("Key Configuration", "Key configuration for the various keyboard shortcuts used by Quantum Console."));

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(_supportedStateProperty, new GUIContent("Enabled", "On which build/editor states should the console be enabled on"));
            ShowSceneViewToggle();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.PropertyField(_activateOnStartupProperty, new GUIContent("Activate on Startup", "If the Quantum Console should be shown and activated on startup."));
            if (!_activateOnStartupProperty.boolValue)
            {
                EditorGUILayout.PropertyField(_initialiseOnStartupProperty, new GUIContent("Initialise on Startup", "If the Quantum Console should be initialised on startup in the background."));
            }

            EditorGUILayout.PropertyField(_closeOnSubmitProperty, new GUIContent("Close on Submit", "If the Quantum Console should be hidden and closed when a command is submitted and invoked."));
            EditorGUILayout.PropertyField(_singletonModeProperty, new GUIContent("Singleton", "Forces the console into singleton mode. " +
                                                                                 "This means the console will be made scene persistent and will not be destroyed when new scenes are loaded. " +
                                                                                 "Additionally, only one instance of the console will be allowed to exist, and it will be accessible via QuantumConsole.Instance"));
            EditorGUILayout.PropertyField(_verboseErrorsProperty, new GUIContent("Verbose Errors", "If errors caused by the Quantum Console Processor or commands should be logged in verbose mode."));
            EditorGUILayout.PropertyField(_autoScrollProperty, new GUIContent("Autoscroll", "Determine if and when the console should autoscroll."));
            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Debug Interception", "All settings relating to the interception of Unity's Debug class."), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(_interceptDebugProperty, new GUIContent("Intercept Debug Messages", "If the Quantum Console should intercept and display messages from the Unity Debug logging."));
            if (_interceptDebugProperty.boolValue)
            {
                EditorGUILayout.PropertyField(_interceptInactiveProperty, new GUIContent("Intercept Whilst Inactive", "If the Quantum Console should continue to intercept messages whilst inactive."));
                EditorGUILayout.PropertyField(_prependTimestampsProperty, new GUIContent("Enable Timestamps", "If the timestamp of the log message should be prepended."));
                EditorGUILayout.PropertyField(_loggingLevelProperty, new GUIContent("Logging Level", "The minimum log severity required to intercept and display the log."));
                EditorGUILayout.PropertyField(_verboseLoggingProperty, new GUIContent("Verbose Logging", "The minimum log severity required to use verbose logging."));
                EditorGUILayout.PropertyField(_openOnLogLevelProperty, new GUIContent("Open Console", "The minimum log severity required to open the console."));
            }
            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Async Settings", "All settings related to async commands."), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(_showCurrentJobsProperty, new GUIContent("Show Current Jobs", "Shows a popup counter with the currently executing async commands."));
            EditorGUILayout.PropertyField(_blockOnAsyncProperty, new GUIContent("Block on Execute", "Blocks the Quantum Console from being used until the current async command has finished."));
            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Command Search", "Settings relating to searching for commands in the console using tab."), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(_fuzzyProperty, new GUIContent("Use Fuzzy Search", "If fuzzy search is disabled, then your current search must match the beginning of the command to be suggested (foo*). If fuzzy search is enabled, it can be anywhere within the command name to be suggested (*foo*)."));
            EditorGUILayout.PropertyField(_caseSensitiveProperty, new GUIContent("Case Sensitive", "If the search should be case sensitive or not."));
            EditorGUILayout.PropertyField(_usePopupProperty, new GUIContent("Show Popup Display", "If enabled, a popup display will be shown containing potential command autocompletions as you type."));
            if (_usePopupProperty.boolValue)
            {
                EditorGUILayout.PropertyField(_maxSuggestionProperty, new GUIContent("Max Suggestion Count", "The maximum number of suggestions to display in the popup. Set to -1 for unlimited."));
                EditorGUILayout.PropertyField(_popupOrderProperty, new GUIContent("Suggestion Popup Order", "The sort direction used when displaying suggestions to the popup display."));
            }
            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Command History", "Settings relating to storing previous commands so that they can be easily accessed with the arrow keys."), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(_commandHistoryProperty, new GUIContent("Store Previous Commands", "If previous commands should be stored, allowing them to be accessed with the arrow keys."));
            if (_commandHistoryProperty.boolValue)
            {
                EditorGUILayout.PropertyField(_commandHistoryDuplicatesProperty, new GUIContent("Allow Duplicates", "Store commands into the history even if they have already appeared."));
                if (_commandHistoryDuplicatesProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(_commandHistoryAdjacentDuplicatesProperty, new GUIContent("Allow Adjacent Duplicates", "Store commands in the history even if they are adjacent duplicates (i.e same command multiple times in a row)."));
                }
                _commandHistorySizeProperty.intValue = Mathf.Max(-1, EditorGUILayout.IntField(new GUIContent("Max Size", "The maximum size of the command history buffer; exceeding this size will cause the oldest commands to be removed to make space. Set to -1 for unlimited."), _commandHistorySizeProperty.intValue));
            }
            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Advanced Settings", "Advanced settings such as buffer sizes."), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(_maxStoredLogsProperty, new GUIContent("Maximum Stored Logs", "Maximum number of logtraces to store before discarding old logs. Set to -1 for unlimited."));
            EditorGUILayout.PropertyField(_showInitLogsProperty, new GUIContent("Show Initialization Logs", "Whether the initialization logs should be shown or not."));
            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("References", "All the references needed by the Quantum Console"), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(_containerProperty, new GUIContent("Container Rect", "The top level container rect-transform containing all of the Quantum Console UI elements."));
            EditorGUILayout.PropertyField(_scrollRectProperty, new GUIContent("Scroll Rect", "(Optional) The scroll rect of the console text, required for autoscrolling."));
            EditorGUILayout.PropertyField(_popupProperty, new GUIContent("Suggestion Popup Display", "Top level transform for the suggestion popup display."));
            EditorGUILayout.PropertyField(_jobCounterRectProperty, new GUIContent("Job Counter Display", "Top level transform for the job counter display."));

            EditorGUILayout.PropertyField(_inputProperty, new GUIContent("Console Input Field", "The input field used for interfacing with the Quantum Console."));
            EditorGUILayout.PropertyField(_inputPlaceholderProperty, new GUIContent("Console Input Placeholder", "The placeholder text component for when the input field is not in use."));
            EditorGUILayout.PropertyField(_popupTextProperty, new GUIContent("Suggestion Popup Text", "Text display for the suggestion popup display."));
            EditorGUILayout.PropertyField(_logProperty, new GUIContent("Console Log Display", "The text display used as the log output by the Quantum Console."));
            EditorGUILayout.PropertyField(_suggestionProperty, new GUIContent("Command Suggestion Display", "(optional) If assigned, the Quantum Console will show the paramater signature for suggested commands here."));
            EditorGUILayout.PropertyField(_jobCounterTextProperty, new GUIContent("Job Counter Text", "Text display for the job counter display."));

            EditorGUILayout.PropertyField(_panelsProperty, new GUIContent("UI Panels", "All panels in the UI to control with the Quantum Theme."), true);

            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 15
0
    //创建预制体
    public void createFromPrefab(string path, UnityObject script)
    {
#if _CLIENTLOGIC_
        PrefabUtil.create(path, script);
#endif
    }
Ejemplo n.º 16
0
        protected virtual void OnBallChanged()
        {
            Ball.Hit += Ball_Hit;

            Cue.DirectionLineCalculator.Projection = PrefabUtil.Create <GameObject>("Projection", "Ball");
        }
Ejemplo n.º 17
0
 public void RefreshList()
 {
     Prefabs = PrefabUtil.FindPrefabs <T>().ToArray();
 }