コード例 #1
0
ファイル: UIManager.cs プロジェクト: dyskotron/Framewerk
        public virtual T CreateComponent <T>(RectTransform parent = null, string customPath = "")
        {
            if (parent == null)
            {
                parent = UIParent();
            }

            var view = Assets.GetAsset <GameObject>(UI_PREFABS_ROOT + SUBFOLDER_COMPONENTS + customPath);

            view.transform.SetParent(parent, false);

            return(view.GetComponent <T>());
        }
コード例 #2
0
        public void NewAssets_UponRefresh_AreAddedToGuidTable()
        {
            CreateDummyScriptWithImporter(k_ScriptAPath);
            CreateDummyScriptWithImporter(k_ScriptBPath);

            AssetManager.Refresh();

            Assert.AreEqual(2, AssetGuidManager.Paths.Count(), "Asset count missmatch");
            Assert.AreEqual(AssetManager.GetAsset(k_ScriptAPath).Guid, AssetGuidManager.GetGuid(k_ScriptAPath), "Asset guid missmatch");
            Assert.AreEqual(AssetManager.GetAsset(k_ScriptBPath).Guid, AssetGuidManager.GetGuid(k_ScriptBPath), "Asset guid missmatch");
        }
コード例 #3
0
        AudioClip GetClip(string soundId)
        {
            AudioClip clipToPlay = null;

            if (m_Leafs.ContainsKey(soundId))
            {
                List <string> audios = m_Leafs[soundId].AudioData;
                if (audios != null && audios.Count > 0)
                {
                    string origPath = "";
                    if (m_Leafs[soundId].SoundRandomization)
                    {
                        origPath = m_Leafs[soundId].RandomWeightedAudioData();
                    }
                    else
                    {
                        origPath = m_Leafs[soundId].GetNextOrderedAudioData();
                    }
                    if (!String.IsNullOrEmpty(origPath))
                    {
                        string path = StripResourcePath(origPath);
                        clipToPlay = assetManager.GetAsset <AudioClip>(path);
                        //clipToPlay = m_Cache.RetainClip(path);
                    }
                }
            }

            return(clipToPlay);
        }
コード例 #4
0
        public Script LoadScript(string path)
        {
            var asset = AssetManager.GetAsset(path);

            if (asset == null)
            {
                Logger.Log(LogType.Error, "Cannot load script. No such asset at path: " + path);
                return(null);
            }

            Profiler.Start("ScriptManager_LoadScript");

            // if hierarchy contains empty untitled script, remove it
            if (m_LoadedScripts.Count == 1 && m_LoadedScripts[0].Name == Script.DefaultScriptName && m_LoadedScripts[0].Commands.Count() == 0)
            {
                RemoveScript(0);
            }

            Script newScript = asset.Importer.ReloadAsset <Script>();

            if (newScript != null)
            {
                newScript.Path = asset.Path;
                AddScript(newScript, true);
            }
            else
            {
                Logger.Log(LogType.Error, "Failed to load script: " + asset.Path);
            }

            Profiler.Stop("ScriptManager_LoadScript");
            return(newScript);
        }
コード例 #5
0
    static int GetAsset(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        IAssetManager obj  = LuaScriptMgr.GetNetObject <IAssetManager>(L, 1);
        string        arg0 = LuaScriptMgr.GetLuaString(L, 2);

        com.gt.assets.IAssetBundle o = obj.GetAsset(arg0);
        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
コード例 #6
0
        private void CreateNewAsset(Bitmap bmp)
        {
            while (true)
            {
                if (AssetManager.GetAsset(GetPathForID(LastCropImageIndex)) != null)
                {
                    LastCropImageIndex++;
                    continue;
                }
                break;
            }

            AssetManager.CreateAsset(bmp, GetPathForID(LastCropImageIndex));
        }
コード例 #7
0
        public void SavingFixtureVia_TestFixtureManager_ProducesCorrectAsset()
        {
            var fixture      = TestFixtureManager.NewTestFixture();
            var lightFixture = LightTestFixture;

            fixture.ApplyLightFixtureValues(lightFixture);
            TestFixtureManager.SaveTestFixture(fixture, k_FixturePath);

            var asset           = AssetManager.GetAsset(k_FixturePath);
            var newLightFixture = asset.Importer.ReloadAsset <LightTestFixture>();

            newLightFixture.Name = lightFixture.Name; // Names are overrided by path they are saved

            CheckIfLightTestFixturesAreEqual(lightFixture, newLightFixture);
        }
コード例 #8
0
        protected override void Initialize()
        {
            base.Initialize();

            var scene = _sceneManager.CreateScene("Test");

            var boidSprite = new Sprite(_assetManager.GetAsset <Texture2D>("boid"));

            // Create target
            var target = new GameObject();

            target.AddComponent <Rigidbody>();
            target.AddComponent <Target>();
            var sr = target.AddComponent <SpriteRenderer>();

            sr.sprite = boidSprite;
            sr.color  = Color.Green;
            scene.AddGameObject(target);

            // Create boids controller
            var flock = new GameObject();
            var f     = flock.AddComponent <Flock>();

            scene.AddGameObject(flock);

            // Create boids
            for (int i = 0; i < 25; i++)
            {
                var boid = new GameObject();
                boid.AddComponent <Rigidbody>();
                sr        = target.AddComponent <SpriteRenderer>();
                sr.sprite = boidSprite;
                var b = boid.AddComponent <Boid>();
                b.Target = target.Transform;
                f.AddBoid(b);
            }

            // Load the scene
            _sceneManager.LoadScene(scene);
        }
コード例 #9
0
ファイル: AssetTests.cs プロジェクト: JustasUnity/MouseRobot
        public void CreateAsset_CreatesFile_AndAddsToAssetManager()
        {
            var script = new Script(guid);

            AssetManager.CreateAsset(script, k_ScriptAPath);

            Assert.IsTrue(File.Exists(k_ScriptAPath), "File was not created");
            Assert.AreEqual(AssetManager.GetAsset(k_ScriptAPath).Importer.Load <Script>(), script, "Asset value did not match the script");
        }
コード例 #10
0
 public Asset GetSelectedAsset()
 {
     return(AssetManager.GetAsset(treeView.SelectedNode.Parent.Text, treeView.SelectedNode.Text));
 }
コード例 #11
0
ファイル: SetupScene.cs プロジェクト: andrecosta/Mini-Prey
        static IScene SetupScene(IAssetManager assetManager)
        {
            // Create scene
            IScene scene = new Scene("Game");

            // Create the human player
            PlayerController player = scene.CreateGameObject <PlayerController>("PlayerController", Vector2.Zero);
            {
                player.TeamColor          = new Color(183, 68, 231);
                player.AttackCommandSound = assetManager.GetAsset <AudioClip>("AttackCommand");
                player.AddComponent <LineRenderer>();
                player.AddComponent <AudioSource>();
            }

            // Create the AI player
            AIController aiPlayer = scene.CreateGameObject <AIController>("AIController", Vector2.Zero);
            {
                aiPlayer.TeamColor = new Color(68, 231, 118);
            }

            // Create the Neutral player
            AIController neutralPlayer = scene.CreateGameObject <AIController>("NeutralController", Vector2.Zero);
            {
                neutralPlayer.TeamColor = new Color(230, 230, 230);
                neutralPlayer.IsNeutral = true;
            }

            // Create the GameController
            GameController gc = scene.CreateGameObject <GameController>("GameController", Vector2.Zero);
            {
                gc.ShipSprite             = new Sprite(assetManager.GetAsset <Texture2D>("ship"));
                gc.ShotSprite             = new Sprite(assetManager.GetAsset <Texture2D>("bullet"));
                gc.OutlineSprite          = new Sprite(assetManager.GetAsset <Texture2D>("outline"));
                gc.RangeSprite            = new Sprite(assetManager.GetAsset <Texture2D>("range"));
                gc.PlanetConqueredSound   = assetManager.GetAsset <AudioClip>("PlanetConquered");
                gc.PlanetSelectSound      = assetManager.GetAsset <AudioClip>("PlanetSelect");
                gc.PlanetUpgradeSound     = assetManager.GetAsset <AudioClip>("PlanetUpgrade");
                gc.ShipShotSound          = assetManager.GetAsset <AudioClip>("ShipShotDown");
                gc.ShipExplosionAnimation = new AnimationClip(new Sprite(assetManager.GetAsset <Texture2D>("ship_explosion")), 7);
                gc.PlanetPopulationFont   = assetManager.GetAsset <Font>("main_font");
                gc.Players = new Player[] { player, aiPlayer, neutralPlayer };

                // Set the planet types and upgrades
                gc.PlanetTypes = new[]
                {
                    new Planet.Type
                    {
                        UpgradeLevels = new[]
                        {
                            new Planet.Upgrade
                            {
                                Cost               = 10,
                                Sprite             = new Sprite(assetManager.GetAsset <Texture2D>("Planet1")),
                                PopGenerationLimit = 20,
                                PopGenerationRate  = 2f
                            },
                            new Planet.Upgrade
                            {
                                Cost               = 15,
                                Sprite             = new Sprite(assetManager.GetAsset <Texture2D>("Planet2")),
                                PopGenerationLimit = 40,
                                PopGenerationRate  = 1.5f
                            },
                            new Planet.Upgrade
                            {
                                Cost               = 20,
                                Sprite             = new Sprite(assetManager.GetAsset <Texture2D>("Planet3")),
                                PopGenerationLimit = 60,
                                PopGenerationRate  = 1f
                            }
                        }
                    },
                    new Planet.Type
                    {
                        UpgradeLevels = new[]
                        {
                            new Planet.Upgrade
                            {
                                Cost     = 10,
                                FireRate = 0.5f,
                                Range    = 120,
                                Sprite   = new Sprite(assetManager.GetAsset <Texture2D>("Sentry1")),
                            },
                            new Planet.Upgrade
                            {
                                Cost     = 20,
                                FireRate = 0.4f,
                                Range    = 170,
                                Sprite   = new Sprite(assetManager.GetAsset <Texture2D>("Sentry2")),
                            },
                            new Planet.Upgrade
                            {
                                Cost     = 30,
                                FireRate = 0.3f,
                                Range    = 210,
                                Sprite   = new Sprite(assetManager.GetAsset <Texture2D>("Sentry3")),
                            }
                        }
                    }
                };

                player.GameController   = gc;
                aiPlayer.GameController = gc;
            }

            // Create the Custom Cursor
            CustomCursor cc = scene.CreateGameObject <CustomCursor>("CustomCursor", Vector2.Zero);
            {
                cc.AddComponent <SpriteRenderer>();
                cc.Percent25Sprite  = new Sprite(assetManager.GetAsset <Texture2D>("cursor_25"));
                cc.Percent50Sprite  = new Sprite(assetManager.GetAsset <Texture2D>("cursor_50"));
                cc.Percent75Sprite  = new Sprite(assetManager.GetAsset <Texture2D>("cursor_75"));
                cc.Percent100Sprite = new Sprite(assetManager.GetAsset <Texture2D>("cursor_100"));
                player.CustomCursor = cc;
            }

            // Create the HUD
            HUD hud = scene.CreateGameObject <HUD>("HUD", Vector2.Zero);

            {
                var leftBar   = scene.CreateGameObject <LineRenderer>("LeftBar", Vector2.Zero);
                var rightBar  = scene.CreateGameObject <LineRenderer>("RightBar", Vector2.Zero);
                var leftText  = scene.CreateGameObject <TextRenderer>("LeftText", Vector2.Zero);
                var rightText = scene.CreateGameObject <TextRenderer>("RightText", Vector2.Zero);

                hud.LeftBar        = leftBar;
                hud.RightBar       = rightBar;
                hud.LeftText       = leftText;
                hud.RightText      = rightText;
                hud.UIFont         = assetManager.GetAsset <Font>("main_font");
                hud.GameController = gc;
            }

            return(scene);
        }