private static SPThreadPool CreateInstance()
        {
            if (object.ReferenceEquals(_instance, null))
            {
                var go = new UnityEngine.GameObject("Spacepuppy.SPThreadPool");
                _instance = go.AddComponent<SPThreadPool>();
                UnityEngine.Object.DontDestroyOnLoad(go);
            }

            return _instance;
        }
示例#2
0
        public void SubscribeOnce()
        {
            var go = new UnityEngine.GameObject();
            var mb = go.AddComponent<UnityEngine.MonoBehaviour>();

            int callNum1 = 0;
            mb.Subscribe("topic1", () => { callNum1++; }).Once();
            Publisher.Publish("topic1");
            Publisher.Publish("topic1");
            Publisher.Publish("topic1");
            Assert.AreEqual(callNum1, 1);
        }
示例#3
0
        public static void paused()
        {
            var gameObject = new UnityEngine.GameObject();

            try
            {
                var service = gameObject.AddComponent <Mux.Platform.TickerService>();
                Assert.IsFalse(service.paused);
            }
            finally
            {
                UnityEngine.Object.Destroy(gameObject);
            }
        }
        public override void Setup()
        {
            base.Setup();
            GameObject = new UnityEngine.GameObject(Entity.GetType().Name);
            var view = GameObject.AddComponent <ComponentView>();

            view.Type                      = GameObject.name;
            view.Component                 = this;
            Entity.OnNameChangedAction     = OnNameChanged;
            Entity.OnAddComponentAction    = OnAddComponent;
            Entity.OnRemoveComponentAction = OnRemoveComponent;
            Entity.OnAddChildAction        = OnAddChild;
            Entity.OnRemoveChildAction     = OnRemoveChild;
        }
示例#5
0
        public static void Load()
        {
            Player_ESPObject = new UnityEngine.GameObject();
            Player_ESPObject.AddComponent <Player_ESP>();
            UnityEngine.Object.DontDestroyOnLoad(Player_ESPObject);

            object_Advanced = new UnityEngine.GameObject();
            object_Advanced.AddComponent <Advanced>();
            UnityEngine.Object.DontDestroyOnLoad(object_Advanced);

            object_Menu = new UnityEngine.GameObject();
            object_Menu.AddComponent <Menu>();
            UnityEngine.Object.DontDestroyOnLoad(object_Menu);
        }
        static StackObject *AddComponent_6(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.GameObject instance_of_this_method = (UnityEngine.GameObject) typeof(UnityEngine.GameObject).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.AddComponent <UnityEngine.Canvas>();

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
示例#7
0
        private void BuildCube(Unity.Mathematics.float4[] vertices, Unity.Mathematics.float3 planePos,
                               Unity.Mathematics.float3 planeNorm)
        {
            UnityEngine.GameObject cube1_go = new UnityEngine.GameObject();
            cube1_go.transform.parent = this.transform;
            cube1_go.AddComponent <IMRE.ScaleDimension.CrossSections.TetrahedronCrossSection>();
            hyperCubeXC.Add(cube1_go.GetComponent <IMRE.ScaleDimension.CrossSections.CubeCrossSection>());

            //TODO project verticies down a dimension.
            //cube1_go.GetComponent<IMRE.ScaleDimension.CrossSections.CubeCrossSecion>().cubeVertices = vertices;
            cube1_go.GetComponent <IMRE.ScaleDimension.CrossSections.TetrahedronCrossSection>().planePos    = planePos;
            cube1_go.GetComponent <IMRE.ScaleDimension.CrossSections.TetrahedronCrossSection>().planeNormal = planeNorm;
            cube1_go.GetComponent <IMRE.ScaleDimension.CrossSections.TetrahedronCrossSection>().mat         = mat;
        }
        public List <object> GetAllInstancesWithInjectSplit(
            InjectContext context, List <TypeValuePair> args, out Action injectAction)
        {
            Assert.IsNotNull(context);

            UnityEngine.GameObject gameObject = _prefabInstantiator.Instantiate(args, out injectAction);

            UnityEngine.Component component = gameObject.AddComponent(_componentType);

            return(new List <object>()
            {
                component
            });
        }
示例#9
0
        /// <summary>
        /// This does the reusable parts of the overloaded Spawn() method.
        /// </summary>
        /// <returns>The spawned game object for Hikari.</returns>
        private static UnityEngine.GameObject StartSpawn( )
        {
            // Error if hikari exists
            if (hikari != null)
            {
                throw new Exception("Cannot spawn a second Hikari instance.");
            }

            // Generate new Hikari and game object.
            UnityEngine.GameObject obj = new UnityEngine.GameObject("Autogenerated_HikariObject");
            DontDestroyOnLoad(obj);
            hikari = obj.AddComponent <Hikari>();

            return(obj);
        }
示例#10
0
文件: Device.cs 项目: yakumo-proj/Mux
        public static void SystemEnabled()
        {
            var gameObject = new UnityEngine.GameObject();

            try
            {
                var service = gameObject.AddComponent <Mux.Platform.TickerService>();
                var ticker  = new Mux.Platform.Ticker(service);
                Assert.That(ticker.SystemEnabled);
            }
            finally
            {
                UnityEngine.Object.Destroy(gameObject);
            }
        }
示例#11
0
        public ICoroutineManager CreateCoroutineManager()
        {
            if (_container == null && _isValid)
            {
                _container           = new UnityEngine.GameObject("JSRuntimeContainer");
                _container.hideFlags = UnityEngine.HideFlags.HideInHierarchy;
                UnityEngine.Object.DontDestroyOnLoad(_container);
            }
            if (_container != null)
            {
                return(_container.AddComponent <Unity.DefaultCoroutineManager>());
            }

            return(null);
        }
        public static T Create <T>(string name, UnityEngine.Transform parent, Vector3 position, Quaternion rotation, Vector3 scale) where T : ChiselNode
        {
            // TODO: ensure we're creating this in the active scene
            // TODO: handle scene being locked by version control

            if (string.IsNullOrEmpty(name))
            {
#if UNITY_EDITOR
                name = UnityEditor.GameObjectUtility.GetUniqueNameForSibling(parent, typeof(T).Name);
#else
                name = typeof(T).Name;
#endif
            }

            var newGameObject = new UnityEngine.GameObject(name);
#if UNITY_EDITOR
            UnityEditor.Undo.RegisterCreatedObjectUndo(newGameObject, "Created " + name);
#endif
            newGameObject.SetActive(false);
            try
            {
                var brushTransform = newGameObject.transform;
#if UNITY_EDITOR
                if (parent)
                {
                    UnityEditor.Undo.SetTransformParent(brushTransform, parent, "Move child node underneath parent operation");
                }
                UnityEditor.Undo.RecordObject(brushTransform, "Move child node to given position");
                brushTransform.localPosition = position;
                brushTransform.localRotation = rotation;
                brushTransform.localScale    = scale;
                return(UnityEditor.Undo.AddComponent <T>(newGameObject));
#else
                if (parent)
                {
                    brushTransform.SetParent(parent, false);
                }
                brushTransform.localPosition = position;
                brushTransform.localRotation = rotation;
                brushTransform.localScale    = scale;
                return(newGameObject.AddComponent <T>());
#endif
            }
            finally
            {
                newGameObject.SetActive(true);
            }
        }
示例#13
0
        static DxDebug()
        {
            if (!isInit)
            {
#if UNITY_EDITOR //已经发布成dll它们不再有效
                 
#endif

#if UNITY_ANDROID
                UnityEngine.GameObject go = new UnityEngine.GameObject("AndroidLog");
                UnityEngine.GameObject.DontDestroyOnLoad(go);
                go.AddComponent <LogGameObject>();
#endif
                isInit = true;
            }
        }
示例#14
0
    static partial void PreGameObjectAPICallUserHook(UnityEngine.GameObject gameObject, ulong id)
    {
        if (!IsInRegisteredList(id))
        {
            //UnityEngine.Debug.Log("Consider adding an AkGameObj to " + gameObject.name);

            // If the object is not active, attaching an AkGameObj will not work.
            if (gameObject == null || !gameObject.activeInHierarchy)
            {
                new AutoObject(gameObject);
            }
            else
            {
                gameObject.AddComponent <AkGameObj>();
            }
        }
    }
示例#15
0
        /** 更新。
         */
        public static void Main(string a_label = nameof(Test_99))
        {
            UnityEngine.Debug.Log("----- " + a_label + " -----");

            try{
                Item t_item_from = new Item();
                {
                    //material
                    t_item_from.material = new UnityEngine.Material(UnityEngine.Shader.Find("Fee/Render2D/Add"));

                    //monobehaviour
                    UnityEngine.GameObject t_gameobject = new UnityEngine.GameObject("gameobject");
                    t_item_from.monobehaviour = t_gameobject.AddComponent <Test_MonoBehaviour>();
                }

                //オブジェクト ==> JSONITEM。
                                #if (FEE_JSON)
                Fee.JsonItem.JsonItem t_jsonitem = Fee.JsonItem.Convert.ObjectToJsonItem <Item>(t_item_from);
                                #endif

                //JSONITEM ==> JSON文字列。
                                #if (FEE_JSON)
                string t_jsonstring = t_jsonitem.ConvertToJsonString();
                                #else
                string t_jsonstring = UnityEngine.JsonUtility.ToJson(t_item_from);
                                #endif

                //JSON文字列 ==> オブジェクト。
                                #if (FEE_JSON)
                Item t_item_to = Fee.JsonItem.Convert.JsonStringToObject <Item>(t_jsonstring);
                                #else
                Item t_item_to = UnityEngine.JsonUtility.FromJson <Item>(t_jsonstring);
                                #endif

                //ログ。
                UnityEngine.Debug.Log(a_label + " : " + t_jsonstring);

                //チェック。
                if (Check(t_item_from, t_item_to) == false)
                {
                    UnityEngine.Debug.LogError("mismatch");
                }
            }catch (System.Exception t_exception) {
                UnityEngine.Debug.LogError(a_label + " : exception : " + t_exception.Message);
            }
        }
        public void copyMesh()
        {
            if (GetComponent <UnityEngine.MeshFilter>() != null)
            {
                childmeshFilt.mesh.SetVertices(
                    System.Linq.Enumerable.ToList(GetComponent <UnityEngine.MeshFilter>().mesh.vertices));
                childmeshFilt.mesh.triangles = GetComponent <UnityEngine.MeshFilter>().mesh.triangles;

                childGameObject.GetComponentInParent <UnityEngine.MeshFilter>().mesh.uv =
                    GetComponent <UnityEngine.MeshFilter>().mesh.uv;

                childGameObject.AddComponent <UnityEngine.MeshRenderer>();
                childGameObject.GetComponent <UnityEngine.MeshRenderer>().material = mat;

                meshCopied = true;
            }
        }
        /* Fast sort, which works off data, rather than visual elements.
         * Since only 7 visual elements are allocated, this is required.
         */
        public List <ListElementController_BASE_NotListView> Sort(List <ListElementController_BASE_NotListView> items)
        {
            LogSpam($"Sorting: {items.Select(item => GetRef(item).ComponentDefID).ToArray().Dump(false)}");

            var sw  = Stopwatch.StartNew();
            var _a  = new ListElementController_InventoryGear_NotListView();
            var _b  = new ListElementController_InventoryGear_NotListView();
            var go  = new UnityEngine.GameObject();
            var _ac = go.AddComponent <InventoryItemElement_NotListView>(); //new InventoryItemElement_NotListView();
            var go2 = new UnityEngine.GameObject();
            var _bc = go2.AddComponent <InventoryItemElement_NotListView>();

            _ac.controller = _a;
            _bc.controller = _b;
            var _cs = new Traverse(inventoryWidget).Field("currentSort").GetValue <Comparison <InventoryItemElement_NotListView> >();
            var cst = _cs.Method;

            LogDebug(string.Format("Sort using {0}::{1}", cst.DeclaringType.FullName, cst.ToString()));

            var tmp = items.ToList();

            tmp.Sort(new Comparison <ListElementController_BASE_NotListView>((l, r) => {
                _ac.ComponentRef          = _a.componentRef = GetRef(l);
                _bc.ComponentRef          = _b.componentRef = GetRef(r);
                _ac.controller            = l;
                _bc.controller            = r;
                _ac.controller.ItemWidget = _ac;
                _bc.controller.ItemWidget = _bc;
                _ac.ItemType = ToDraggableType(l.componentDef);
                _bc.ItemType = ToDraggableType(r.componentDef);
                var res      = _cs.Invoke(_ac, _bc);
                LogSpam($"Compare {_a.componentRef.ComponentDefID}({_ac != null},{_ac.controller.ItemWidget != null}) & {_b.componentRef.ComponentDefID}({_bc != null},{_bc.controller.ItemWidget != null}) -> {res}");
                return(res);
            }));

            UnityEngine.GameObject.Destroy(go);
            UnityEngine.GameObject.Destroy(go2);

            var delta = sw.Elapsed.TotalMilliseconds;

            LogInfo(string.Format("Sorted in {0} ms", delta));

            LogSpam($"Sorted: {tmp.Select(item => GetRef(item).ComponentDefID).ToArray().Dump(false)}");

            return(tmp);
        }
示例#18
0
        //Attach to the modded dll
        public override void Initialize()
        {
            Log("Randomizer Mod initializing!");

            instance = this;

            ModHooks.Instance.GetPlayerBoolHook += Randomizer.GetPlayerDataBool;
            ModHooks.Instance.SetPlayerBoolHook += Randomizer.SetPlayerDataBool;
            ModHooks.Instance.GetPlayerIntHook  += Randomizer.GetPlayerDataInt;
            ModHooks.Instance.SetPlayerIntHook  += Randomizer.SetPlayerDataInt;
            ModHooks.Instance.SavegameLoadHook  += LogSetting;
            ModHooks.Instance.SavegameClearHook += Randomizer.DeleteGame;
            ModHooks.Instance.NewGameHook       += Randomizer.NewGame;

            UnityEngine.SceneManagement.SceneManager.activeSceneChanged += SceneHandler.CheckForChanges;

            ModHooks.Instance.LanguageGetHook += LanguageHandler.Get;
            UnityEngine.GameObject UIObj = new UnityEngine.GameObject();
            UIObj.AddComponent <GUIController>();
            UnityEngine.GameObject.DontDestroyOnLoad(UIObj);

            //Get version from XML
            if (File.Exists(@"Randomizer\randomizer.xml"))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(@"Randomizer\randomizer.xml");
                XmlAttribute ver = doc.SelectSingleNode("randomizer").Attributes["version"];
                if (ver != null)
                {
                    xmlVer = ver.Value;
                }
            }

            try
            {
                Randomizer.LoadEntriesFromXML();
                Randomizer.xmlLoaded = true;
            }
            catch (Exception e)
            {
                LogError("Failed to load XML:\n" + e);
            }

            Log("Randomizer Mod initialized!");
        }
示例#19
0
        static StackObject *AddComponent_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Type @componentType = (System.Type) typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.GameObject instance_of_this_method = (UnityEngine.GameObject) typeof(UnityEngine.GameObject).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.AddComponent(@componentType);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
示例#20
0
        public static int AddComponent(IntPtr L)
        {
            int result = 1;
            int count  = LuaDLL.lua_gettop(L);

            if (count != 2)
            {
                LuaStatic.traceback(L, "count not enough");
                LuaDLL.lua_error(L);
                return(result);
            }
            UnityEngine.GameObject obj = LuaStatic.GetObj(L, 1) as UnityEngine.GameObject;
            object type1 = LuaStatic.GetObj(L, 2);
            Type   arg1  = LuaStatic.GetType(type1);

            LuaStatic.addGameObject2Lua(L, obj.AddComponent(arg1), (string)type1);
            return(result);
        }
示例#21
0
        /** ミラー。作成。
         */
        public MirrorObject_MonoBehaviour CreateMirror(Fee.Mirror.RenderTextureSizeType a_size_type, UnityEngine.GameObject a_mirror_object, UnityEngine.Camera a_look_camera, string a_name)
        {
            if (a_mirror_object != null)
            {
                MirrorCamera_MonoBehaviour t_mirror_camera = MirrorCamera_MonoBehaviour.Create(a_size_type, a_name);

                //ミラーマテリアル。設定。
                UnityEngine.Renderer t_renderer = a_mirror_object.GetComponent <UnityEngine.Renderer>();
                if (t_renderer != null)
                {
                    UnityEngine.Shader t_shader = UnityEngine.Shader.Find(Config.SHADER_NAME_MIRROR);
                    if (t_shader != null)
                    {
                        t_renderer.material = new UnityEngine.Material(t_shader);
                        t_renderer.material.SetTexture("texture_mirror", t_mirror_camera.GetRenderTexture());
                    }
                    else
                    {
                        Tool.Assert(false);
                    }
                }
                else
                {
                    Tool.Assert(false);
                }

                //ミラーオブジェクト。設定。
                MirrorObject_MonoBehaviour t_mirror_object = a_mirror_object.AddComponent <MirrorObject_MonoBehaviour>();
                {
                    t_mirror_object.mirror_camera  = t_mirror_camera;
                    t_mirror_object.look_camera    = a_look_camera;
                    t_mirror_object.look_transform = a_look_camera.GetComponent <UnityEngine.Transform>();
                    t_mirror_object.enabled        = false;
                }

                return(t_mirror_object);
            }
            else
            {
                Tool.Assert(false);
            }

            return(null);
        }
示例#22
0
        /** 追加。
         */
        public static UnityEngine.GameObject Add(UnityEngine.GameObject a_prefab, ResourceItem[] a_resource_list)
        {
            try{
                //texture_list
                TextureList_MonoBehaviour t_texture_list = a_prefab.AddComponent <TextureList_MonoBehaviour>();

                t_texture_list.tag_list     = new string[a_resource_list.Length];
                t_texture_list.texture_list = new UnityEngine.Texture2D[a_resource_list.Length];
                for (int ii = 0; ii < t_texture_list.texture_list.Length; ii++)
                {
                    t_texture_list.tag_list[ii]     = a_resource_list[ii].tag;
                    t_texture_list.texture_list[ii] = Fee.EditorTool.Utility.LoadAsset <UnityEngine.Texture2D>(a_resource_list[ii].path);
                }
            }catch (System.Exception t_exception) {
                UnityEngine.Debug.LogError(t_exception.Message);
            }

            return(a_prefab);
        }
        static StackObject* AddComponent_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.GameObject instance_of_this_method = (UnityEngine.GameObject)typeof(UnityEngine.GameObject).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.AddComponent<global::MonoBehaviourAdapter.Adaptor>();

            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }
示例#24
0
        public World GetWorld(bool bCreate)
        {
            if (System.Object.ReferenceEquals(m_world, null))
            {
                //check if an Workspace is already in the scene
                //m_world = UnityEngine.Object.FindObjectOfType(typeof(World)) as World;
                if (bCreate && System.Object.ReferenceEquals(m_world, null))
                {
                    UnityEngine.GameObject o = new UnityEngine.GameObject("_world_");

                    UnityEngine.GameObject.DontDestroyOnLoad(o);
                    m_world = o.AddComponent <DefaultWorld>();
                }
            }

            //Debug.Check(m_world != null);

            return(m_world);
        }
示例#25
0
        /** 追加。
         */
        public static UnityEngine.GameObject Add(UnityEngine.GameObject a_prefab, ResourceItem[] a_resource_list)
        {
            try{
                //audiovolume_list
                AudioVolumeList_MonoBehaviour t_audiovolume_list = a_prefab.AddComponent <AudioVolumeList_MonoBehaviour>();

                t_audiovolume_list.tag_list         = new string[a_resource_list.Length];
                t_audiovolume_list.audiovolume_list = new float[a_resource_list.Length];
                for (int ii = 0; ii < t_audiovolume_list.audiovolume_list.Length; ii++)
                {
                    t_audiovolume_list.tag_list[ii]         = a_resource_list[ii].tag;
                    t_audiovolume_list.audiovolume_list[ii] = a_resource_list[ii].volume;
                }
            }catch (System.Exception t_exception) {
                UnityEngine.Debug.LogError(t_exception.Message);
            }

            return(a_prefab);
        }
示例#26
0
        int UnityEngineGameObject_m_AddComponent(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;


            UnityEngine.GameObject gen_to_be_invoked = (UnityEngine.GameObject)translator.FastGetCSObj(L, 1);


            {
                System.Type _componentType = (System.Type)translator.GetObject(L, 2, typeof(System.Type));

                UnityEngine.Component gen_ret = gen_to_be_invoked.AddComponent(_componentType);
                translator.Push(L, gen_ret);



                return(1);
            }
        }
        private Collision MoveGameObjectWithCollisions(
            UnityEngine.GameObject colliderGameObject,
            UnityEngine.Vector3 move)
        {
            var recordCollidee =
                colliderGameObject.AddComponent <RecordCollidee>();

            controller.Move(move);
            var collideeGameObject = recordCollidee.Collidee;

            UnityEngine.Object.Destroy(recordCollidee);
            if (collideeGameObject == null)
            {
                return(null);
            }
            return(CollisionBetweenGameObjects(
                       colliderGameObject,
                       collideeGameObject));
        }
示例#28
0
        /** 追加。
         */
        public static UnityEngine.GameObject Add(UnityEngine.GameObject a_prefab, ResourceItem[] a_resource_list)
        {
            try{
                //materialclip_list
                MaterialList_MonoBehaviour t_material_list = a_prefab.AddComponent <MaterialList_MonoBehaviour>();

                t_material_list.tag_list      = new string[a_resource_list.Length];
                t_material_list.material_list = new UnityEngine.Material[a_resource_list.Length];
                for (int ii = 0; ii < t_material_list.material_list.Length; ii++)
                {
                    t_material_list.tag_list[ii]      = a_resource_list[ii].tag;
                    t_material_list.material_list[ii] = Fee.EditorTool.AssetTool.LoadAsset <UnityEngine.Material>(a_resource_list[ii].path);
                }
            }catch (System.Exception t_exception) {
                UnityEngine.Debug.LogError(t_exception.Message);
            }

            return(a_prefab);
        }
示例#29
0
        /// <summary>
        /// Adds a first person camera to the view type.
        /// </summary>
        /// <param name="cameraController">The camera controller that contains the view type.</param>
        /// <param name="viewType">The first person view type.</param>
        public static void AddFirstPersonCamera(CameraController cameraController, FirstPersonController.Camera.ViewTypes.FirstPerson viewType)
        {
            // A first person camera must be added to the first peron view types.
            cameraController.DeserializeViewTypes();
            var viewTypes = cameraController.ViewTypes;

            UnityEngine.Camera firstPersonCamera = null;
            FirstPersonController.Camera.ViewTypes.FirstPerson firstPersonViewType;
            for (int i = 0; i < viewTypes.Length; ++i)
            {
                if ((firstPersonViewType = viewTypes[i] as FirstPersonController.Camera.ViewTypes.FirstPerson) != null &&
                    firstPersonViewType.FirstPersonCamera != null)
                {
                    firstPersonCamera = firstPersonViewType.FirstPersonCamera;
                    break;
                }
            }

            // If the camera is null then a new first person camera should be created.
            if (firstPersonCamera == null)
            {
                UnityEngine.Transform firstPersonCameraTransform;
                if ((firstPersonCameraTransform = cameraController.transform.Find("First Person Camera")) != null)
                {
                    firstPersonCamera = firstPersonCameraTransform.GetComponent <UnityEngine.Camera>();
                }

                if (firstPersonCamera == null)
                {
                    var cameraGameObject = new UnityEngine.GameObject("First Person Camera");
                    cameraGameObject.transform.SetParentOrigin(cameraController.transform);
                    firstPersonCamera               = cameraGameObject.AddComponent <UnityEngine.Camera>();
                    firstPersonCamera.clearFlags    = UnityEngine.CameraClearFlags.Depth;
                    firstPersonCamera.fieldOfView   = 60f;
                    firstPersonCamera.nearClipPlane = 0.01f;
                    firstPersonCamera.depth         = 0;
                    firstPersonCamera.renderingPath = cameraController.GetComponent <UnityEngine.Camera>().renderingPath;
                }
            }

            viewType.FirstPersonCamera = firstPersonCamera;
        }
示例#30
0
        public static void Load()
        {
            DisableAnticheat();
            while (BaseObject = UnityEngine.GameObject.Find("TemSharp"))
            {
                UnityEngine.Object.Destroy(BaseObject);
            }
            BaseObject = new UnityEngine.GameObject("TemSharp");
            UnityEngine.Object.DontDestroyOnLoad(BaseObject);
            BaseObject.SetActive(false);
            var types = Assembly.GetExecutingAssembly().GetTypes().ToList().Where(t => t.BaseType == typeof(UnityEngine.MonoBehaviour) && !t.IsNested);

            foreach (var type in types)
            {
                var component = (UnityEngine.MonoBehaviour)BaseObject.AddComponent(type);
                component.enabled = false;
            }
            BaseObject.GetComponent <Menu>().enabled = true;
            BaseObject.SetActive(true);
        }
        static StackObject *AddComponent_12(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.GameObject instance_of_this_method = (UnityEngine.GameObject) typeof(UnityEngine.GameObject).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.AddComponent <JEngine.Core.ClassBind>();

            object obj_result_of_this_method = result_of_this_method;

            if (obj_result_of_this_method is CrossBindingAdaptorType)
            {
                return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance));
            }
            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
示例#32
0
            public virtual void AddChild(object obj)
            {
                XElement ele   = (XElement)obj;
                var      child = new Node(triggerName, this, nodeClassify, nodeType, layer + 1, childList.Count, DeleteChild);

                child.name = ele.Attribute("name").Value;
                if (ele.Attribute("component") != null)
                {
                    string component          = ele.Attribute("component").Value;
                    Type   type               = Type.GetType(component + ", Assembly-CSharp");
                    UnityEngine.GameObject ro = UnityEngine.GameObject.Find("[Trigger]");
                    if (ro == null)
                    {
                        ro = new UnityEngine.GameObject("[Trigger]");
                    }
                    var triggerparent = UnityEngine.GameObject.Find("[Trigger]/" + triggerName);
                    if (triggerparent == null)
                    {
                        triggerparent = new UnityEngine.GameObject(triggerName);
                        triggerparent.transform.parent = ro.transform;
                    }
                    var parent = UnityEngine.GameObject.Find("[Trigger]/" + triggerName + "/" + nodeClassify.ToString());
                    if (parent == null)
                    {
                        parent = new UnityEngine.GameObject(nodeClassify.ToString());
                        parent.transform.parent = triggerparent.transform;
                    }
                    UnityEngine.GameObject o = new UnityEngine.GameObject(child.name);
                    o.transform.parent = parent.transform;
                    o.AddComponent(type);
                }
                child.content = new XElement(ele.Name);
                foreach (var item in ele.Attributes())
                {
                    child.content.SetAttributeValue(item.Name, item.Value);
                }
                child.content.Add(ele.Elements());
                child.menulist = menulist;
                childList.Add(child);
            }
示例#33
0
 public static void EnsureInitialized()
 {
     try
     {
         if (EventPump.Instance == null)
         {
             lock (s_Lock)
             {
                 if (EventPump.Instance == null)
                 {
                     UnityEngine.GameObject parent = new UnityEngine.GameObject("Kinect Desktop Event Pump");
                     EventPump.Instance = parent.AddComponent<Helper.EventPump>();
                     DontDestroyOnLoad(parent);
                 }
             }
         }
     }
     catch
     {
         UnityEngine.Debug.LogError("Events must be registered on the main thread.");
         return;
     }
 }
示例#34
0
        /// <summary>
        /// This does the reusable parts of the overloaded Spawn() method.
        /// </summary>
        /// <returns>The spawned game object for Hikari.</returns>
        private static UnityEngine.GameObject StartSpawn ( )
        {
            // Error if hikari exists
            if ( hikari != null )
                throw new Exception("Cannot spawn a second Hikari instance.");

            // Generate new Hikari and game object.
            UnityEngine.GameObject obj = new UnityEngine.GameObject("Autogenerated_HikariObject");
            DontDestroyOnLoad(obj);
            hikari = obj.AddComponent<Hikari>();

            return obj;
        }