Exemplo n.º 1
0
 public virtual void SaveScene(string state)
 {
     this.SetPath(state);
     Debug.Log("Saving " + Serializer.scenePath);
     foreach (var script in Locate.GetSceneComponents <MonoBehaviour>())
     {
         var serializable = script.GetAttributedVariables(typeof(Store).AsArray());
         if (serializable.Count < 1)
         {
             continue;
         }
         var output = new StringBuilder();
         foreach (var target in serializable)
         {
             var name  = target.Key;
             var value = target.Value;
             output.Append(this.Save(name, value));
         }
         var contents = output.ToString().TrimRight(this.Separator());
         if (!contents.IsEmpty())
         {
             var id = script.GetInstanceID().ToString().Replace("-", "n");
             output.Prepend(this.Hash(id), this.Separator());
             this.GetFile(script).Write(output.ToString().Trim(this.Separator()));
         }
     }
     File.CheckSave();
 }
Exemplo n.º 2
0
        public virtual void LoadInstances()
        {
            var instances = File.FindAll(Serializer.scenePath + "/", false);
            var lookup    = new Dictionary <int, MonoBehaviour>();

            foreach (var script in Locate.GetSceneComponents <MonoBehaviour>())
            {
                lookup[script.GetInstanceID()] = script;
            }
            foreach (var instanceFile in instances)
            {
                Debug.Log("Parsing : " + instanceFile.path);
                var lines      = instanceFile.ReadText().Split(this.Separator());
                var instanceID = lines.First().Trim("[", "]").ToInt();
                if (lookup.ContainsKey(instanceID))
                {
                    var instance = lookup[instanceID];
                    foreach (var line in lines.Skip(1))
                    {
                        if (line.Trim().IsEmpty())
                        {
                            continue;
                        }
                        var data = this.Parse(line);
                        this.LoadValue(instance, data.Key, data.Value);
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void UpdateEffects()
 {
                 #if UNITY_EDITOR
     var updateShaders   = PlayerPref.Get <bool>("EditorSettings-AlwaysUpdateShaders");
     var updateParticles = PlayerPref.Get <bool>("EditorSettings-AlwaysUpdateParticles");
     if (updateShaders)
     {
         Shader.SetGlobalFloat("timeConstant", Time.Get());
     }
     foreach (var system in Locate.GetSceneComponents <ParticleSystem>())
     {
         if (system.IsNull())
         {
             continue;
         }
         var updater = system.gameObject.GetComponent <UpdateParticle>();
         if (updateParticles && updater.IsNull())
         {
             updater           = system.gameObject.AddComponent <UpdateParticle>();
             updater.hideFlags = HideFlags.DontSaveInBuild | HideFlags.NotEditable | HideFlags.HideInInspector;
         }
         if (!updateParticles && !updater.IsNull())
         {
             DestroyImmediate(updater);
         }
     }
     if (updateShaders || updateParticles)
     {
         ProxyEditor.RepaintSceneView();
     }
                 #endif
 }
Exemplo n.º 4
0
 static Variable()
 {
     foreach (var component in Locate.GetSceneComponents <Component>())
     {
         foreach (var variable in component.GetVariables <Variable>())
         {
             Variable.Add(component, variable.Key, variable.Value);
         }
     }
 }
Exemplo n.º 5
0
        public static void RefreshTables()
        {
            var tables = Locate.GetSceneComponents <StateTable>().Where(x => !x.IsNull()).OrderBy(x => x.GetPath().Length);

            tables.Reverse();
            foreach (var table in tables)
            {
                table.Refresh();
                table.UpdateStates();
            }
        }
Exemplo n.º 6
0
        public void AssignProfile(string[] values)
        {
            if (values.Length < 2)
            {
                return;
            }
            var inputInstances = Locate.GetSceneComponents <InputInstance>().ToList();
            var instance       = inputInstances.Find(x => x.alias == values[1]);

            this.SelectProfile(instance);
        }
        public static void RefreshScene()
        {
            List <Material> materials = new List <Material>();
            var             renderers = Locate.GetSceneComponents <Renderer>();

            foreach (var renderer in renderers)
            {
                materials.AddRange(renderer.sharedMaterials);
            }
            materials = materials.Distinct().ToList();
            Events.AddStepper("On Editor Update", VariableMaterialEditor.RefreshStep, materials, 50);
        }
Exemplo n.º 8
0
 public static void SetupColliders()
 {
     foreach (var collider in Locate.GetSceneComponents <Collider>())
     {
         if (collider.IsNull() || collider.gameObject.IsNull())
         {
             continue;
         }
         Events.Register("On Collision", collider.gameObject);
         Events.Register("On Collision Start", collider.gameObject);
         Events.Register("On Collision End", collider.gameObject);
     }
     Events.Add("On Level Was Loaded", ColliderController.SetupColliders).SetPermanent();
     Events.Add("On Components Changed", ColliderController.SetupColliders).SetPermanent();
 }
Exemplo n.º 9
0
        public void Setup()
        {
            ProgramManager.singleton = this;
            this.vsync = QualitySettings.vSyncCount;
            Events.Register("On Resolution Change");
            Events.Add("On Editor Update", this.UpdateEffects);
            Events.Add("On Enter Play", this.UpdateEffects);
            Application.targetFrameRate = this.maxFPS;
            var screen = Screen.currentResolution;

            this.resolution = new int[2] {
                Screen.width, Screen.height
            };
            Locate.GetSceneComponents <Persistent>().Where(x => x.activateOnLoad).ToList().ForEach(x => x.gameObject.SetActive(true));
            this.DetectResolution();
        }
Exemplo n.º 10
0
 public void RemoveProfile(string name)
 {
     if (File.Find(name + ".profile", false).IsNull())
     {
         this.ShowProfiles();
         this.selectionHeader = "Remove Profile";
         Events.AddLimited("On Profile Selected", () => this.RemoveProfile(this.activeProfile.name), 1, this);
         return;
     }
     this.profiles.RemoveAll(x => x.name == name);
     File.Delete(name + ".profile");
     foreach (var instance in Locate.GetSceneComponents <InputInstance>())
     {
         if (!instance.profile.IsNull() && instance.profile.name == name)
         {
             this.instanceProfile.Remove(instance.alias);
             InputManager.Get().SelectProfile(instance);
         }
     }
 }
Exemplo n.º 11
0
        public void SceneRefresh()
        {
            bool fullSweep = !Proxy.IsPlaying();

            if (fullSweep)
            {
                Attribute.all.Clear();
                Attribute.lookup.Clear();
            }
            bool includeEnabled  = Attribute.ready || !Proxy.IsPlaying();
            bool includeDisabled = !Attribute.ready || this.editorIncludeDisabled;

            if (Attribute.debug.Has("ProcessRefresh"))
            {
                Log.Editor("[AttributeManager] Scene Refreshing...");
            }
            this.data = Locate.GetSceneComponents <DataBehaviour>(includeEnabled, includeDisabled);
            if (Attribute.debug.Has("ProcessRefresh"))
            {
                Log.Editor("[AttributeManager] DataBehaviour Count : " + this.data.Length);
            }
            this.start     = Time.Get();
            this.nextIndex = 0;
        }