示例#1
0
        static public GameObject EmitDebugLine(string name, Vector3f start, Vector3f end, float diameter, Colorf startColor, Colorf endColor,
                                               GameObject parent = null, bool bIsInWorldPos = true)
        {
            if (FPlatform.InMainThread() == false)
            {
                ThreadMailbox.PostToMainThread(() => { DebugUtil.EmitDebugLine(name, start, end, diameter, startColor, endColor, parent, bIsInWorldPos); });
                return(null);
            }

            GameObject line = new GameObject();

            line.SetName(name);
            line.transform.position = (bIsInWorldPos) ? start : Vector3f.Zero;
            line.AddComponent <LineRenderer>();
            LineRenderer lr = line.GetComponent <LineRenderer>();

            lr.material   = MaterialUtil.CreateParticlesMaterial();
            lr.startColor = startColor;
            lr.endColor   = endColor;
            lr.startWidth = lr.endWidth = diameter;
            lr.SetPosition(0, start);
            lr.SetPosition(1, end);

            if (parent != null)
            {
                lr.useWorldSpace = bIsInWorldPos;
                line.transform.SetParent(parent.transform, bIsInWorldPos);
            }

            return(line);
        }
示例#2
0
    GameObject build_more_flyout()
    {
        GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu"));

        popupGO.SetName("MoreSceneMenu");

        CCUIBuilder.AddBasicToolButton(popupGO, "New Scene", on_clear_scene_clicked);

        Canvas.AddChild(popupGO, false);

        // [RMS] I have no idea what is going on here...but this does work

        RectTransform    targetRect  = moreButton.gameObject.GetComponent <RectTransform>();
        AxisAlignedBox2f targetBox   = targetRect.rect;
        Vector2f         targetPoint = BoxModel.GetBoxPosition(ref targetBox, BoxPosition.TopRight);
        Vector3f         targetW     = moreButton.gameObject.transform.TransformPoint(targetPoint.x, targetPoint.y, 0);

        //RectTransform popupRect = popupGO.GetComponent<RectTransform>();
        //AxisAlignedBox2f popupBox = popupRect.rect;
        //Vector2f popupCorner = BoxModel.GetBoxPosition(ref popupBox, BoxPosition.TopLeft);
        //Vector3f popupW = popupGO.transform.TransformPoint(popupCorner.x, popupCorner.y, 0);
        //Vector2f popupCenter = BoxModel.GetBoxPosition(ref popupBox, BoxPosition.Center);
        //Vector3f popupC = popupGO.transform.TransformPoint(popupCenter.x, popupCenter.y, 0);
        //Vector3f dl = popupW - popupC;

        //Vector3f dx = popupW - targetW;

        Vector3f shift = new Vector3f(5, 5, 0);

        popupGO.transform.position = targetW + shift;


        return(popupGO);
    }
示例#3
0
        static public GameObject EmitDebugAABB(string name, Vector3 center, Vector3f dims, Color color, GameObject inCoords = null)
        {
            if (FPlatform.InMainThread() == false)
            {
                ThreadMailbox.PostToMainThread(() => { DebugUtil.EmitDebugAABB(name, center, dims, color, inCoords); });
                return(null);
            }

            if (inCoords != null)
            {
                Transform curt = inCoords.transform;
                while (curt != null)
                {
                    center = curt.TransformPoint(center);
                    curt   = curt.parent;
                }
            }
            GameObject box = GameObject.CreatePrimitive(PrimitiveType.Cube);

            box.SetName(name);
            box.transform.position   = center;
            box.transform.localScale = dims;
            box.GetComponent <MeshRenderer> ().material.color = color;
            return(box);
        }
        public static void CreateGraph()
        {
            var graph = new GameObject().AddComponent <UniGraph>();

            graph.SetName(graph.name);

            //add main root node
            var root = graph.AddNode <UniPortNode>(DefaultInputNodeName);

            root.name      = DefaultInputNodeName;
            root.direction = PortIO.Input;

            var activePath = AssetDatabase.GetAssetPath(Selection.activeObject);

            var assetFolder = Directory.Exists(activePath) ? activePath : Path.GetDirectoryName(activePath);

            var assetGameObject = graph.gameObject.SaveAsset(DefaultGraphName, assetFolder);

            graph = assetGameObject.GetComponent <UniGraph>();

            AssetDatabase.Refresh();

            var serializableGraph = ScriptableObject.CreateInstance <UniGraphAsset>();

            graph.serializedGraph  = serializableGraph;
            serializableGraph.name = graph.name;
            serializableGraph.SaveAssetAsNested(graph.gameObject);
            graph.gameObject.MarkDirty();
        }
        public static void CMD_AppendNumber(GameObject obj)
        {
            IEnumerable <GameObject> objenum = null;

            if (obj.transform.GetParent() == null)
            {
                objenum = EngineManagerViewModel.instance.CurrentGameObjects.AsEnumerable <GameObject>();
            }
            else
            {
                Converters.CTransformListToGameObjectListConverter conv = new Converters.CTransformListToGameObjectListConverter();
                objenum = (conv.Convert(obj.transform.GetParent().children, null, null, null) as ObservableCollection <GameObject>).AsEnumerable <GameObject>();
            }
            string obj_name = obj.GetName();

            for (int i = 0; i < obj_name.Length; ++i)
            {
                if (char.IsDigit(obj_name[i]))
                {
                    obj_name = obj_name.Remove(i);
                    break;
                }
            }
            obj_name = obj_name.Trim();
            int index = objenum.Count(new Func <GameObject, bool>((GameObject g) => { return(g.GetName().Contains(obj_name)); }));

            obj.SetName(obj_name + " " + index.ToString());
        }
示例#6
0
        static public GameObject EmitDebugLine(string name, Vector3f start, Vector3f end, float diameter, Colorf startColor, Colorf endColor,
                                               GameObject parent = null, bool bIsInWorldPos = true)
        {
            GameObject line = new GameObject();

            line.SetName(name);
            line.transform.position = (bIsInWorldPos) ? start : Vector3f.Zero;
            line.AddComponent <LineRenderer>();
            LineRenderer lr = line.GetComponent <LineRenderer>();

            lr.material   = new Material(Shader.Find("Particles/Alpha Blended Premultiply"));
            lr.startColor = startColor;
            lr.endColor   = endColor;
            lr.startWidth = lr.endWidth = diameter;
            lr.SetPosition(0, start);
            lr.SetPosition(1, end);

            if (parent != null)
            {
                lr.useWorldSpace = bIsInWorldPos;
                line.transform.SetParent(parent.transform, bIsInWorldPos);
            }

            return(line);
        }
示例#7
0
        static public GameObject EmitDebugCurve(string name, Vector3d[] curve, bool bClosed,
                                                float diameter, Colorf startColor, Colorf endColor,
                                                GameObject parent = null, bool bIsInWorldPos = true)
        {
            GameObject line = new GameObject();

            line.SetName(name);
            line.AddComponent <LineRenderer> ();
            LineRenderer lr = line.GetComponent <LineRenderer> ();

            lr.material   = new Material(Shader.Find("Particles/Alpha Blended Premultiply"));
            lr.startColor = startColor;
            lr.endColor   = endColor;
            lr.startWidth = lr.endWidth = diameter;
            Vector3[] verts = new Vector3[curve.Length];
            for (int i = 0; i < curve.Length; ++i)
            {
                verts[i] = (Vector3)curve[i];
            }
            lr.numPositions = curve.Length;
            lr.SetPositions(verts);
            lr.useWorldSpace = (parent == null && bIsInWorldPos);

            if (parent != null)
            {
                line.transform.SetParent(parent.transform, bIsInWorldPos);
            }

            return(line);
        }
示例#8
0
        // these should be called by parent Unity functions
        public void Start(ICockpitInitializer setup)
        {
            // create invisible plane for cockpit
            gameobject = GameObject.CreatePrimitive(PrimitiveType.Plane);
            gameobject.SetName("cockpit");
            MeshRenderer ren = gameobject.GetComponent <MeshRenderer> ();

            ren.enabled = false;
            gameobject.GetComponent <MeshCollider> ().enabled = false;

            // add hud animation controller
            gameobject.AddComponent <UnityPerFrameAnimationBehavior>().Animator = HUDAnimator;

            // create HUD
            try {
                setup.Initialize(this);
            } catch (Exception e) {
                DebugUtil.Log(2, "[Cockpit.Start] exception in initializer: {0}\nTrace:\n{1}", e.Message,
                              e.StackTrace);
                // if hud setup fails we still want to keep going
            }

            // position in front of camera
            UpdateTracking(true);
        }
示例#9
0
        public fLinesGameObject(GameObject baseGO, string name = "line")
            : base(baseGO, FGOFlags.EnablePreRender)
        {
            baseGO.SetName(name);

            // ugly...
            __VectrosityConfig.Configure();

            if (baseGO.GetComponent <MeshFilter>() == null)
            {
                baseGO.AddComponent <MeshFilter>();
            }
            if (baseGO.GetComponent <MeshRenderer>() == null)
            {
                baseGO.AddComponent <MeshRenderer>();
            }

            List <Vector3> vertices = new List <Vector3>()
            {
                Vector3.zero, Vector3.one
            };

            vectorLine = new VectorLine(name, vertices, width, LineType.Discrete);
            VectorManager.ObjectSetup(baseGO, vectorLine, Visibility.Dynamic, Brightness.None);
        }
示例#10
0
        public virtual T AddElement()
        {
            T pElem = new GameObject().AddComponent <T>();

            pElem.transform.parent = transform;
            pElem.Build();
            pElem.SetName();
            return(pElem);
        }
示例#11
0
 public static GameObject Attach(this Transform transform, string word, GameObject prefab)
 {
     {
         GameObject instance = Object.Instantiate(prefab);
         instance.transform.SetParent(transform, false);
         instance.SetName($"Button {word}").SetTextInChildren(word);
         return(instance);
     }
 }
示例#12
0
 public static void Setup()
 {
     button = Utilities.CloneGameObject(PATH_TO_GAMEOBJECT_TO_CLONE, PATH_TO_CLONE_PARENT);
     button.GetRectTrans().SetAnchoredPos(Constants.FRIEND_BUTTON_POS); //213f, 315f
     button.SetName(GAMEOBJECT_NAME);
     button.SetText(BUTTON_DEFAULT_TEXT);
     button.SetButtonActionInChildren(onClick);
     button.SetActive(true);
     initialised = true;
 }
示例#13
0
 public void Start()
 {
     fadeObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
     //fadeObject.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
     fadeObject.GetComponent <MeshRenderer>().material = MaterialUtil.CreateFlatMaterial(Color.black, 0.0f);
     fadeObject.SetName("fade_sphere");
     UnityUtil.ReverseMeshOrientation(fadeObject.GetMesh());
     fadeObject.transform.SetParent(UseCamera.transform, false);
     fadeObject.SetLayer(FPlatform.HUDLayer);
 }
示例#14
0
        public LevelEvent AddElement()
        {
            LevelEvent pElem = new GameObject().AddComponent <LevelEvent>();

            pElem.transform.parent        = transform;
            pElem.transform.localPosition = Vector3.zero;
            pElem.Build();
            pElem.SetName();
            return(pElem);
        }
示例#15
0
 public static void Setup()
 {
     button = Utilities.CloneGameObject(PATH_TO_GAMEOBJECT_TO_CLONE, PATH_TO_CLONE_PARENT);
     button.GetRectTrans().SetAnchoredPos(Constants.WORLD_BUTTON_POS);
     button.SetName(Constants.WORLD_BUTTON_NAME);
     button.SetText(Constants.BUTTON_IDLE_TEXT);
     button.SetButtonAction(onClick);
     button.SetActive(true);
     initialised = true;
 }
示例#16
0
        public void Start()
        {
            ShowTarget = false;

            targetGO        = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            visibleMaterial = MaterialUtil.CreateTransparentMaterial(Color.red, 0.8f);
            hiddenMaterial  = MaterialUtil.CreateTransparentMaterial(Color.red, 0.4f);
            targetGO.GetComponent <MeshRenderer>().material = hiddenMaterial;
            targetGO.SetLayer(FPlatform.WidgetOverlayLayer);
            MaterialUtil.DisableShadows(targetGO);
            targetGO.SetName("camera_target");
        }
示例#17
0
    public void OnStart()
    {
        sound = gameObject.RequireComponent <CSound>();

        consoleText = Common.GetSurveillancePlayerConsoleText().RequireComponent <CFontRenderer>();
        // consoleText.mFontSize = 60;
        // consoleText.mFontScale = 0.0024f;

        mBlinkingTimer         = 0.0f;
        consoleText.mText      = "";
        firstLineTextToDisplay = "";
        btmTextToDisplay       = "";

        playerMouse    = GetScript <Mouse>(Common.GetStealthPlayerMouse());
        player         = Common.GetStealthPlayer();
        mBlinkingLight = GetScript <OcuConsoleBlinkingLight>(Common.GetConsoleBlinkingLight());

        mCenterPosForText   = Common.GetConsoleCam().transform.position; // console: -10, 25
        mCenterPosForText.Z = consoleText.gameObject.transform.position.z;

        mExtraTexts = new List <GameObject>();

        if (mColorOfText == null || mColorOfText.Comp(SharpMocha.BLACK))
        {
            mColorOfText = mDColorOfText;
        }

        mHeaderTextObj = ObjectFactory.getInstance().Instantiate(Common.nameForFixedWidthText);
        mHeaderTextObj.SetName("ConsoleHeaderText");
        Vector3 headerPos = mCenterPosForText;

        headerPos.X -= 3.3f; //-13.40, 26.8
        headerPos.Y += 1.8f;
        mHeaderTextObj.transform.SetPosition(headerPos);
        mHeaderFont                = mHeaderTextObj.GetComponent <CFontRenderer>();
        mHeaderFont.mText          = "";
        mHeaderFont.mJustification = CFontRenderer.FONT_JUSTIFICATION.LEFT_JUSTIFIED;

        ChangeHeader(defaultHeaderText);

        mNextMessageTimer = 0.0f;
        mMessageQueue     = new LinkedList <Tuple <String, float, bool> >();
        QueueMessage("System Initializing...", 0.0f, false, false);
        QueueMessage("Enabling Camera Systems.", 0.7f, false, false);
        QueueMessage("Enabling Map Systems.", 0.4f, false, false);
        QueueMessage("Enabling Door Security Systems.", 0.3f, false, false);
        QueueMessage("System Ready.", 0.7f, false, false);

        mTextToDisplay.AddFirst("> ");
        UpdateConsoleTextFromQueue();
        hasConsoleTextChanged = 0;
    }
示例#18
0
    GameObject build_modeltools_flyout()
    {
        GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu"));

        popupGO.SetName("PrintUtilTools");

        CCUIBuilder.AddBasicStartToolButton(popupGO, "Plane Cut", PlaneCutTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Add Hole", AddHoleTool.Identifier, single_selection_or_one_obj);

        Canvas.AddChild(popupGO, false);
        UnityUIUtil.PositionRelative2D(popupGO, BoxPosition.TopLeft, Panel, BoxPosition.TopRight, Vector2f.Zero);

        return(popupGO);
    }
示例#19
0
    GameObject build_tritools_flyout()
    {
        GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu"));

        popupGO.SetName("PositionTools");

        CCUIBuilder.AddBasicStartToolButton(popupGO, "Remesh", RemeshTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Simplify", ReduceTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Map to Target", ReprojectTool.Identifier, pair_selection);

        Canvas.AddChild(popupGO, false);
        UnityUIUtil.PositionRelative2D(popupGO, BoxPosition.TopLeft, Panel, BoxPosition.TopRight, Vector2f.Zero);

        return(popupGO);
    }
示例#20
0
    GameObject build_print_util_popup()
    {
        GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu"));

        popupGO.SetName("PrintUtilTools");

        CCUIBuilder.AddBasicStartToolButton(popupGO, "Brim", BrimTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Purge Spiral", PurgeSpiralTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Block Support", GenerateBlockSupportsTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Tree Support", GenerateGraphSupportsTool.Identifier);

        Canvas.AddChild(popupGO, false);
        UnityUIUtil.PositionRelative2D(popupGO, BoxPosition.TopLeft, Panel, BoxPosition.TopRight, Vector2f.Zero);

        return(popupGO);
    }
示例#21
0
        static public GameObject EmitDebugSphere(string name, Vector3 position, float diameter, Color color, GameObject parent = null, bool bIsInWorldPos = true)
        {
            GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            sphere.SetName(name);
            sphere.transform.position   = position;
            sphere.transform.localScale = new Vector3(diameter, diameter, diameter);
            sphere.GetComponent <MeshRenderer> ().material.color = color;

            if (parent != null)
            {
                sphere.transform.SetParent(parent.transform, bIsInWorldPos);
            }

            return(sphere);
        }
示例#22
0
 public static void Setup()
 {
     gameObject = Utilities.CloneGameObject(PATH_TO_GAMEOBJECT_TO_CLONE, PATH_TO_CLONE_PARENT);
     gameObject.GetRectTrans().SetAnchoredPos(Constants.DWLD_STATUS_POS);
     if (ModSettings.showStatusOnQM && !ModSettings.hideQMStatusWhenInActive)
     {
         gameObject.SetActive(true);
     }
     else
     {
         gameObject.SetActive(false);
     }
     gameObject.SetName(Constants.DOWNLOAD_STATUS_NAME);
     gameObject.GetComponent <DebugDisplayText>().enabled = false;
     gameObject.GetComponent <Text>().alignment           = TextAnchor.UpperRight;
     gameObject.SetText(Constants.DOWNLOAD_STATUS_IDLE_TEXT);
 }
示例#23
0
    GameObject build_objects_popup()
    {
        GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu"));

        popupGO.SetName("ObjectsTools");

        CCUIBuilder.AddBasicStartToolButton(popupGO, "Add Shape", GenerateShapeTool.Identifier);
        CCUIBuilder.AddBasicToolButton(popupGO, "Resize", set_size_clicked);
        CCUIBuilder.AddBasicToolButton(popupGO, "Duplicate", on_duplicate_clicked, any_so_selected);
        CCUIBuilder.AddBasicToolButton(popupGO, "Delete", on_delete_clicked, any_so_selected);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Separate", SeparateSolidsTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Combine", CombineMeshesTool.Identifier, multi_selection_or_multi_obj);

        Canvas.AddChild(popupGO, false);
        UnityUIUtil.PositionRelative2D(popupGO, BoxPosition.TopLeft, Panel, BoxPosition.TopRight, Vector2f.Zero);

        return(popupGO);
    }
示例#24
0
    GameObject build_position_popup()
    {
        GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu"));

        popupGO.SetName("PositionTools");

        CCUIBuilder.AddBasicToolButton(popupGO, "On Bed", on_bed_clicked);
        CCUIBuilder.AddBasicToolButton(popupGO, "Center", center_clicked);
        CCUIBuilder.AddBasicToolButton(popupGO, "Swap Y/Z Up", swap_up_clicked);
        CCUIBuilder.AddBasicToolButton(popupGO, "Mirror", mirror_clicked);
        CCUIBuilder.AddBasicToolButton(popupGO, "Reset Pivot", reset_pivot_clicked);
        CCUIBuilder.AddBasicToolButton(popupGO, "Set Base", set_base_clicked, single_so_selected);

        Canvas.AddChild(popupGO, false);
        UnityUIUtil.PositionRelative2D(popupGO, BoxPosition.TopLeft, Panel, BoxPosition.TopRight, Vector2f.Zero);

        return(popupGO);
    }
示例#25
0
    GameObject build_heal_flyout()
    {
        GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu"));

        popupGO.SetName("HealTools");

        CCUIBuilder.AddBasicStartToolButton(popupGO, "AutoRepair", MeshAutoRepairTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Solidify", GenerateClosedMeshTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Weld Edges", WeldEdgesTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Fix Normals", RepairOrientationTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Fill Holes", FillHolesTool.Identifier, single_selection_or_one_obj);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Remove Hidden", RemoveHiddenFacesTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Edit Mesh", MeshEditorTool.Identifier, single_selection_or_one_obj);

        Canvas.AddChild(popupGO, false);
        UnityUIUtil.PositionRelative2D(popupGO, BoxPosition.TopLeft, Panel, BoxPosition.TopRight, Vector2f.Zero);

        return(popupGO);
    }
示例#26
0
        static public GameObject EmitDebugAABB(string name, Vector3 center, Vector3f dims, Color color, GameObject inCoords = null)
        {
            if (inCoords != null)
            {
                Transform curt = inCoords.transform;
                while (curt != null)
                {
                    center = curt.TransformPoint(center);
                    curt   = curt.parent;
                }
            }
            GameObject box = GameObject.CreatePrimitive(PrimitiveType.Cube);

            box.SetName(name);
            box.transform.position   = center;
            box.transform.localScale = dims;
            box.GetComponent <MeshRenderer> ().material.color = color;
            return(box);
        }
示例#27
0
    GameObject build_voxtools_flyout()
    {
        GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu"));

        popupGO.SetName("VoxelTools");

        CCUIBuilder.AddBasicStartToolButton(popupGO, "Solidify", GenerateClosedMeshTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Shell", MeshShellTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "VoxWrap", MeshWrapTool.Identifier);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "VoxBoolean", MeshVoxelBooleanTool.Identifier, multi_selection);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "VoxBlend", MeshVoxelBlendTool.Identifier, multi_selection);
        CCUIBuilder.AddBasicStartToolButton(popupGO, "Morphology", MeshMorphologyTool.Identifier);


        Canvas.AddChild(popupGO, false);
        UnityUIUtil.PositionRelative2D(popupGO, BoxPosition.TopLeft, Panel, BoxPosition.TopRight, Vector2f.Zero);

        return(popupGO);
    }
示例#28
0
        public static void CreateGraph()
        {
            var graph = new GameObject().AddComponent <UniGraph>();

            graph.SetName(graph.name);

            //add main root node
            var root = graph.AddNode <UniPortNode>(DefaultInputNodeName);

            root.name      = DefaultInputNodeName;
            root.direction = PortIO.Input;

            var activePath = AssetDatabase.GetAssetPath(Selection.activeObject);

            var assetFolder = Directory.Exists(activePath) ? activePath :
                              Path.GetDirectoryName(activePath);

            AssetEditorTools.SaveAsset(graph.gameObject, DefaultGraphName, assetFolder);
        }
示例#29
0
 static public GameObject EmitDebugCursorSphere(string name, float diameter, Color color)
 {
     if (FContext.ActiveContext_HACK.MouseCameraController is VRMouseCursorController)
     {
         GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
         sphere.SetName(name);
         sphere.transform.position =
             (FContext.ActiveContext_HACK.MouseCameraController as VRMouseCursorController).CurrentCursorPosWorld;
         sphere.transform.localScale = new Vector3(diameter, diameter, diameter);
         sphere.GetComponent <MeshRenderer>().material =
             MaterialUtil.CreateTransparentMaterial(color, 0.5f);
         MaterialUtil.DisableShadows(sphere);
         sphere.SetLayer(FPlatform.HUDLayer);
         return(sphere);
     }
     else
     {
         throw new Exception("DebugUtil.EmitDebugCursorSphere: only works for VRMouseCursorController!");
     }
 }
示例#30
0
        public static void Setup()
        {
            button = Utilities.CloneGameObject(PATH_TO_GAMEOBJECT_TO_CLONE, PATH_TO_CLONE_PARENT);
            button.GetRectTrans().SetAnchoredPos(Constants.FRIEND_BUTTON_POS);  //213f, 315f
            button.SetName(GAMEOBJECT_NAME);
            button.SetText(BUTTON_DEFAULT_TEXT);
            button.SetButtonActionInChildren(onClick);
            GameObject.Destroy(GameObject.Find(PATH_TO_GAMEOBJECT_TO_DESTROY));

            Transform background = GameObject.Find(PATH_TO_BACKGROUND).transform;

            background.localScale    = new Vector3(background.localScale.x, Constants.FRIEND_PANEL_YSCALE, background.localScale.z);
            background.localPosition = new Vector3(background.localPosition.x, Constants.FRIEND_PANEL_YPOS, background.localPosition.z);

            Transform userInfoPanel = GameObject.Find(PATH_TO_INFO_PANEL).transform;

            userInfoPanel.localPosition = new Vector3(userInfoPanel.localPosition.x, Constants.SOCIAL_PANEL_YPOS, userInfoPanel.localPosition.z);
            button.SetActive(true);
            initialised = true;
        }
示例#31
0
 public static void CMD_AppendNumber(GameObject obj)
 {
     IEnumerable<GameObject> objenum = null;
     if (obj.transform.GetParent() == null)
         objenum = EngineManagerViewModel.instance.CurrentGameObjects.AsEnumerable<GameObject>();
     else
     {
         Converters.CTransformListToGameObjectListConverter conv = new Converters.CTransformListToGameObjectListConverter();
         objenum = (conv.Convert(obj.transform.GetParent().children,null, null, null) as ObservableCollection<GameObject>).AsEnumerable<GameObject>();
     }
     string obj_name = obj.GetName();
     for (int i = 0; i < obj_name.Length; ++i)
     {
         if (char.IsDigit(obj_name[i]))
         {
             obj_name = obj_name.Remove(i);
             break;
         }
     }
     obj_name = obj_name.Trim();
     int index = objenum.Count(new Func<GameObject,bool>((GameObject g)=>{ return g.GetName().Contains(obj_name); }));
     obj.SetName(obj_name + " " + index.ToString());
 }
示例#32
0
    // Adds to the camInMap, camInMapArea, and camInWorld lists
    public static void AddCameraObjectToList(GameObject inCamInWorld, out GameObject retCamInMap, out GameObject retCamInMapArea)
    {
        // Ensure they are initialized
        GetCamsInMap();
        GetCamsInMapArea();
        GetCamsInWorld();

        retCamInMap = null;
        retCamInMapArea = null;

        if (inCamInWorld.GetName().StartsWith(nameForCamInWorld))
        {
            // Sort and change name based on CamInWorld (parent)'s name
            String camIndexStr1 = inCamInWorld.transform.GetParent().gameObject.GetName();
            camIndexStr1 = camIndexStr1.Substring(nameForCamInWorldParent.Length);
            int index = Convert.ToInt32(camIndexStr1);

            inCamInWorld.SetName(nameForCamInWorld + camIndexStr1);
            //String camIndexStr = inCamInWorld.GetName().Substring(nameForCamInWorld.Length);
            //int index = Convert.ToInt32(camIndexStr);

            camInWorld.Add(inCamInWorld);
            // Sort the physical CamInWorld# by name, so [0] == CamInMap1 and so on, with StickyCamInMap being the last
            camInWorld.Sort(CompareCamInWorld);

            retCamInMapArea = null;

            retCamInMap = ObjectFactory.getInstance().Instantiate("CamInMap");
            retCamInMap.SetName(nameForCamInMap + index.ToString());
            for (uint i = 0; i < retCamInMap.transform.GetNumberOfChildren(); ++i)
            {
                if (retCamInMap.transform.GetChild(i).gameObject.GetName() == nameForCamInMapArea)
                {
                    retCamInMapArea = retCamInMap.transform.GetChild(i).gameObject;
                    retCamInMapArea.SetName(nameForCamInMapArea + index.ToString());
                    camInMapArea.Add(retCamInMapArea);
                    break;
                }
            }
            retCamInMap.transform.SetParent(GetMapScreen().transform.GetParent());
            camInMap.Add(retCamInMap);
            camInMap.Sort(CompareCamInMap);

            camInMapArea.Sort(CompareCamInMapArea);
        }
        else
        {
            Logger.Log("Adding camera to list: name not normal: " + inCamInWorld.GetName());

            if (inCamInWorld.GetName() == nameForStickyCamInWorld)
            {
                stickCam = inCamInWorld;
                retCamInMap = ObjectFactory.getInstance().Instantiate("CamInMap");
                retCamInMap.SetName(nameForStickyCamInMap);
                for (uint i = 0; i < retCamInMap.transform.GetNumberOfChildren(); ++i)
                {
                    if (retCamInMap.transform.GetChild(i).gameObject.GetName() == nameForCamInMapArea)
                    {
                        retCamInMapArea = retCamInMap.transform.GetChild(i).gameObject;
                        retCamInMapArea.SetName(nameForStickyCamInMap + "Area");
                        stickCamInMapArea = retCamInMapArea;
                        break;
                    }
                }
                retCamInMap.transform.SetParent(GetMapScreen().transform.GetParent());

                stickCamInMap = retCamInMap;
            }
            else if (inCamInWorld.GetName() == nameForRCCarCamInWorld)
            {
                rcCarCam = inCamInWorld;
                retCamInMap = ObjectFactory.getInstance().Instantiate("CamInMap");
                retCamInMap.SetName(nameForRCCarCamInMap);
                for (uint i = 0; i < retCamInMap.transform.GetNumberOfChildren(); ++i)
                {
                    if (retCamInMap.transform.GetChild(i).gameObject.GetName() == nameForCamInMapArea)
                    {
                        retCamInMapArea = retCamInMap.transform.GetChild(i).gameObject;
                        retCamInMapArea.SetName(nameForRCCarCamInMap + "Area");
                        break;
                    }
                }
                retCamInMap.transform.SetParent(GetMapScreen().transform.GetParent());

                rcCarCamInMap = retCamInMap;
            }
        }
    }
    public void OnStart()
    {
        sound = gameObject.RequireComponent<CSound>();

        consoleText = Common.GetSurveillancePlayerConsoleText().RequireComponent<CFontRenderer>();
        // consoleText.mFontSize = 60;
        // consoleText.mFontScale = 0.0024f;

        mBlinkingTimer = 0.0f;
        consoleText.mText = "";
        firstLineTextToDisplay = "";
        btmTextToDisplay = "";

        playerMouse = GetScript<Mouse>(Common.GetStealthPlayerMouse());
        player = Common.GetStealthPlayer();
        mBlinkingLight = GetScript<OcuConsoleBlinkingLight>(Common.GetConsoleBlinkingLight());

        mCenterPosForText = Common.GetConsoleCam().transform.position; // console: -10, 25
        mCenterPosForText.Z = consoleText.gameObject.transform.position.z;

        mExtraTexts = new List<GameObject>();

        if (mColorOfText == null || mColorOfText.Comp(SharpMocha.BLACK))
        {
            mColorOfText = mDColorOfText;
        }

        mHeaderTextObj = ObjectFactory.getInstance().Instantiate(Common.nameForFixedWidthText);
        mHeaderTextObj.SetName("ConsoleHeaderText");
        Vector3 headerPos = mCenterPosForText;
        headerPos.X -= 3.3f; //-13.40, 26.8
        headerPos.Y += 1.8f;
        mHeaderTextObj.transform.SetPosition(headerPos);
        mHeaderFont = mHeaderTextObj.GetComponent<CFontRenderer>();
        mHeaderFont.mText = "";
        mHeaderFont.mJustification = CFontRenderer.FONT_JUSTIFICATION.LEFT_JUSTIFIED;

        ChangeHeader(defaultHeaderText);

        mNextMessageTimer = 0.0f;
        mMessageQueue = new LinkedList<Tuple<String, float, bool> >();
        QueueMessage("System Initializing...", 0.0f, false, false);
        QueueMessage("Enabling Camera Systems.", 0.7f, false, false);
        QueueMessage("Enabling Map Systems.", 0.4f, false, false);
        QueueMessage("Enabling Door Security Systems.", 0.3f, false, false);
        QueueMessage("System Ready.", 0.7f, false, false);

        mTextToDisplay.AddFirst("> ");
        UpdateConsoleTextFromQueue();
        hasConsoleTextChanged = 0;
    }