当前位置: 首页>>代码示例>>C#>>正文


C# SceneObject.Destroy方法代码示例

本文整理汇总了C#中SceneObject.Destroy方法的典型用法代码示例。如果您正苦于以下问题:C# SceneObject.Destroy方法的具体用法?C# SceneObject.Destroy怎么用?C# SceneObject.Destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SceneObject的用法示例。


在下文中一共展示了SceneObject.Destroy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UnitTest1_ManagedSerialization

        /// <summary>
        /// Tests managed object serialization and deserialization.
        /// </summary>
        static void UnitTest1_ManagedSerialization()
        {
            SceneObject otherSO = new SceneObject("OtherSO");
            UT1_Component2 dbgComponent2 = otherSO.AddComponent<UT1_Component2>();
            dbgComponent2.a2 = 33;

            SceneObject so = new SceneObject("TestSO");
            UT1_Component1 dbgComponent = so.AddComponent<UT1_Component1>();

            dbgComponent.a = 5;
            dbgComponent.b = "SomeTestVal";
            dbgComponent.complex.someValue = 19;
            dbgComponent.complex.anotherValue = "AnotherValue";
            dbgComponent.complex2.someValue2 = 21;
            dbgComponent.complex2.anotherValue2 = "AnotherValue2";

            dbgComponent.arrA = new int[5];
            dbgComponent.arrA[4] = 5;
            dbgComponent.arrB = new string[5];
            dbgComponent.arrB[4] = "ArrAnotherValue";
            dbgComponent.arrComplex = new UT1_SerzObj[5];
            dbgComponent.arrComplex[4].someValue = 99;
            dbgComponent.arrComplex[4].anotherValue = "ArrComplexAnotherValue";
            dbgComponent.arrComplex2 = new UT1_SerzCls[5];
            dbgComponent.arrComplex2[4] = new UT1_SerzCls();
            dbgComponent.arrComplex2[4].someValue2 = 101;
            dbgComponent.arrComplex2[4].anotherValue2 = "ArrComplex2AnotherValue";

            dbgComponent.listA = new List<int>();
            dbgComponent.listA.Add(5);
            dbgComponent.listB = new List<string>();
            dbgComponent.listB.Add("ListAnotherValue");
            dbgComponent.listB.Add(null);
            dbgComponent.listComplex = new List<UT1_SerzObj>();
            dbgComponent.listComplex.Add(new UT1_SerzObj());
            dbgComponent.listComplex.Add(new UT1_SerzObj(99, "ListComplexAnotherValue"));
            dbgComponent.listComplex2 = new List<UT1_SerzCls>();
            dbgComponent.listComplex2.Add(new UT1_SerzCls());
            dbgComponent.listComplex2[0].someValue2 = 101;
            dbgComponent.listComplex2[0].anotherValue2 = "ListComplexAnotherValue";
            dbgComponent.listComplex2.Add(null);

            dbgComponent.dictA = new Dictionary<int, string>();
            dbgComponent.dictA[5] = "value";
            dbgComponent.dictA[10] = "anotherValue";

            dbgComponent.dictB = new Dictionary<string, UT1_SerzObj>();
            dbgComponent.dictB["key1"] = new UT1_SerzObj(99, "DictComplexValue");

            dbgComponent.otherComponent = dbgComponent2;
            dbgComponent.otherSO = otherSO;

            Internal_UT1_GameObjectClone(so);

            System.Diagnostics.Debug.Assert(so.GetNumChildren() == 1);

            for (int i = 0; i < so.GetNumChildren(); i++)
            {
                SceneObject childSO = so.GetChild(i);

                UT1_Component1 otherComponent = childSO.GetComponent<UT1_Component1>();
                DebugUnit.Assert(otherComponent.a == 5);
                DebugUnit.Assert(otherComponent.b == "SomeTestVal");
                DebugUnit.Assert(otherComponent.complex.someValue == 19);
                DebugUnit.Assert(otherComponent.complex2.anotherValue2 == "AnotherValue2");

                DebugUnit.Assert(otherComponent.arrA[4] == 5);
                DebugUnit.Assert(otherComponent.arrB[4] == "ArrAnotherValue");
                DebugUnit.Assert(otherComponent.arrComplex[4].someValue == 99);
                DebugUnit.Assert(otherComponent.arrComplex2[4].anotherValue2 == "ArrComplex2AnotherValue");

                DebugUnit.Assert(otherComponent.listA[0] == 5);
                DebugUnit.Assert(otherComponent.listB[0] == "ListAnotherValue");
                DebugUnit.Assert(otherComponent.listComplex[1].someValue == 99);
                DebugUnit.Assert(otherComponent.listComplex2[0].anotherValue2 == "ListComplexAnotherValue");
            }

            so.Destroy();
            otherSO.Destroy();
        }
开发者ID:BearishSun,项目名称:BansheeEngine,代码行数:83,代码来源:UnitTests.cs

示例2: PostInput

        /// <inheritdoc/>
        protected internal override void PostInput()
        {
            if (activeHandle != null)
            {
                if (activeHandle.IsDragged())
                {
                    if (!isDragged)
                    {
                        isDragged = true;

                        SceneObject[] selectedSceneObjects = Selection.SceneObjects;
                        activeSelection = new HandledObject[selectedSceneObjects.Length];
                        for (int i = 0; i < selectedSceneObjects.Length; i++)
                            activeSelection[i] = new HandledObject(selectedSceneObjects[i]);

                        initialHandlePosition = activeHandle.Position;
                        initialHandleRotation = activeHandle.Rotation;
                    }
                }
                else
                {
                    isDragged = false;
                    activeSelection = null;
                }

                activeHandle.PostInput();

                if (activeHandle.IsDragged())
                {
                    switch (activeHandleType)
                    {
                        case SceneViewTool.Move:
                            MoveHandle moveHandle = (MoveHandle) activeHandle;

                            foreach (var selectedObj in activeSelection)
                                selectedObj.so.LocalPosition = selectedObj.initialPosition + moveHandle.Delta;

                            break;
                        case SceneViewTool.Rotate:
                        {
                            RotateHandle rotateHandle = (RotateHandle) activeHandle;

                            // Make sure we transform relative to the handle position
                            SceneObject temporarySO = new SceneObject("Temp");
                            temporarySO.Position = initialHandlePosition;
                            temporarySO.LocalRotation = initialHandleRotation;

                            SceneObject[] originalParents = new SceneObject[activeSelection.Length];
                            for (int i = 0; i < activeSelection.Length; i++)
                            {
                                originalParents[i] = activeSelection[i].so.Parent;
                                activeSelection[i].so.LocalPosition = activeSelection[i].initialPosition;
                                activeSelection[i].so.LocalRotation = activeSelection[i].initialRotation;
                                activeSelection[i].so.Parent = temporarySO;
                            }

                            temporarySO.LocalRotation *= rotateHandle.Delta;

                            for (int i = 0; i < activeSelection.Length; i++)
                                activeSelection[i].so.Parent = originalParents[i];

                            temporarySO.Destroy();
                        }
                            break;
                        case SceneViewTool.Scale:
                        {
                            ScaleHandle scaleHandle = (ScaleHandle) activeHandle;

                            // Make sure we transform relative to the handle position
                            SceneObject temporarySO = new SceneObject("Temp");
                            temporarySO.Position = activeHandle.Position;

                            SceneObject[] originalParents = new SceneObject[activeSelection.Length];
                            for (int i = 0; i < activeSelection.Length; i++)
                            {
                                originalParents[i] = activeSelection[i].so.Parent;
                                activeSelection[i].so.LocalPosition = activeSelection[i].initialPosition;
                                activeSelection[i].so.LocalRotation = activeSelection[i].initialRotation;
                                activeSelection[i].so.LocalScale = activeSelection[i].initialScale;
                                activeSelection[i].so.Parent = temporarySO;
                            }

                            temporarySO.LocalScale += scaleHandle.Delta;

                            for (int i = 0; i < activeSelection.Length; i++)
                                activeSelection[i].so.Parent = originalParents[i];

                            temporarySO.Destroy();
                        }
                            break;
                    }

                    EditorApplication.SetSceneDirty();
                }
            }
            else
            {
                isDragged = false;
                activeSelection = null;
//.........这里部分代码省略.........
开发者ID:Ruu,项目名称:BansheeEngine,代码行数:101,代码来源:DefaultHandleManager.cs


注:本文中的SceneObject.Destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。